Drupal7 Displayed Username different from Username Entry Field - drupal-7

On our Drupal 7 site, we're trying to force Drupal to use a certain username- First Name, Last Initial - no matter what the user puts in the username field on the user form. Currently, there are fields for Username, First Name, and Last Name. Does anyone have an easy way to do this? It would also be nice if the user profile's URL would take be forced to use the Drupal-created username.
I've looked around and haven't seen any questions on this- let me know if I missed one!

There is a module that do just that RealName and it fairly easy to use and this is the documentation for the module if needed.
and you can alter the user profile link with Pathauto to what ever you want.

Related

mgt-react PeoplePicker defaultSelectedUsers not working as I would expect

I've been writing a React app that relies on the mgt-react components.
The app is basically just an interface to a SharePoint library.
Everything has been working great and the PeoplePicker is working in so much as I can start typing a users name and the drop down works and I can select a person.
However now I'm at the point where I want to create an edit screen. In order to implement this I need to prepopulate the PeoplePicker with the users that were input at insert time.
I can't seem to get the "defaultSelectedUsers" property to work.
I've pared things down to simply hardcoding a users email address and it still doesn't work.
Here is my code for the component (email address changed for privacy reasons):
<PeoplePicker defaultSelectedUsers={['user#domain.com']} selectionMode="single" selectionChanged={handleSelectionChanged}></PeoplePicker>
No matter what I do it is not prepopulating with a user / person.
The permissions are all there (I think) which is proven by the component working when I start typing a user name.
Any ideas what I might be missing?
As always thanks so much for any input in advance.
----- edit ----
Oh okay, it seems that I can't use that prop with mgt-react? I have to use defultSelectedUserIds and can't just provide an email address. Can someone confirm this is the case?
Is there mgt documentation for the defaultSelectedUsers property? As far as I am aware, the people picker only supports defaultSelectedUsersById. The email address should work though, assuming the graph is able to retrieve the users (it's their actual id).
For a quick test, are you able to retrieve the users through the graph explorer with the /users/${id} (replace id with your email) filter? This is what we use for the property.

Next.js - How to show post name in the url instead of the id and make it unique?

I searched for this but I could only find examples in Laravel and PHP, and I need to know how to do this with Next.js.
All I know is that I can do dynamic routes in Next.js the usual way like this ...
/pages/post/[postId] which will translate to /pages/post/23435 for example, and that way if someone has the URL I could just grab the [postId] with router.query and can show the correct post to the user, easy enough.
But what if I want to show the post name in the URL instead of the id? just like what Udemy does with dashes between the words ...
https://www.udemy.com/course/your-custom-react-component/learn/lecture/
And at the same time if someone has that URL I could still show the correct post to them?
I know I could just do /pages/post/[postName] and show the post name in the URL, but that won't be unique, and won't be able to show the correct post.
How can I do that?
You can to do it with postName as you propose, and then take care that postNames are unique and that each one maps to a postId (that's something you need to deal with on your side; so in your database you would generate a unique slug for each postName)
Another solution would be to show both the name and the id like /pages/post/[postName]/[postId]. You can use several params, check https://nextjs.org/docs/routing/dynamic-routes

Drupal Replacement Pattern for Entity Reference

I have a Profile Type attached to a user. In there I have a Entity Reference Field of Program Manager. I have Live Events(content-type) that people can register for. I set up a Rule to Email the Program Manager every time someone registers.
My problem is I am trying to pull information from the Profile based on the the entity reference for the Program Manager.
I have the field printing out by using this pattern...
[registration:entity:field_program_manager]
However when I try to pull the first name, email of phone I can not get it to show up.
Does anyone have any ideas to share?
Many Thanks!
Okay so I was trying to solve for sending the email to the Author of the page but was having issues. So I created a new fields hoping it would be easier. In trying to solve for this I solved the original issue.
To print the Author of a node to an email through Rules actions us this.
[registration:entity:author]
So for first name it would be:
[registration:entity:author:profile-main:field_first_name]
Hope it helps someone else.
If you're using entityform instead of a node and referencing the default user info (not the 'Main Profile' profile type), then you want to use something like
[entityform:field-staff-entity-ref:field-work-email]
In this case, 'field-staff-entity-ref' is the entity reference field in the entityform and 'field-work-email' is the field in the user's account settings.

Website "you can do this" script

I want to create a training path for new users accessing my site. This training path must display info bubbles showing what you can do on every page, but only the first time you access it.
So, for example, if a user enters a page where there's an edit button an info box should appear next to the edit button telling the user that he can edit that page.
I will create the script myself, I just want to know what's the best method to check if the user has already seen that box or not. I was thinking about storing in database a boolean value for each info box which will be set to true if the user has seen the box. To save some queries from the DB I think I can also store the same values in localStorage or in Cookies.
What is the best practice for creating user training paths for a website?
The way I suggest is to store user id (ip or username ? ) and a bit value for each bubble like you say.
PS: for your script you can use this:
http://www.maxvergelli.com/jquery-bubble-popup/documentation/
Jérôme

Output User firstname lastname as link to profile in Drupal 7 views

In Drupal 7, I'm trying to output a list of users related to a node in a view, which I've got working fine.
However, the only way to link to the user profile is to use the user:name field in views, which gives me the markup
username.
I've got two additional profile fields, user:Firstname and user:Lastname, but can't see to find a way to do this:
[user:firstname] [user:lastname]
as each time I try and rewrite the output of the link, it refuses to work; user:url doesn't exist as option in my views UI (which contains the link I need according to Devel).
Thoughts?
I've not used it. But my educated guess is that the easiest solution for you would be to look at the realname module, which should do all the heavy lifting for you.

Resources