mb_user_profile_register Form does not show if already logged in
Support › MB User Profile › mb_user_profile_register Form does not show if already logged inResolved
- This topic has 6 replies, 2 voices, and was last updated 5 years ago by
Content Pilot.
-
AuthorPosts
-
April 22, 2020 at 12:19 AM #19198
Content Pilot
ParticipantHi, I built a site that was running 1.1.3 of this plugin and after looking through the changelog, I see that on 1.4.0 there was an is_user_logged_in flag place before displaying this form. This means that if a user is logged in, say, as the administrator, they cannot register new user accounts for other people. I think I understand that this form is now being used to register the person looking at the website versus how I was using it and that is why it is hidden if the person is already a user and already logged in.
Is there another way I can expose a user registration form where an admin sees the form and registers other user accounts?
I would like to update all the way to 1.6.3, the current head, but I need to fix my functionality first.
April 22, 2020 at 2:34 PM #19218Long Nguyen
ModeratorHi,
Unfortunately, the plugin only supports to register when the user is not logged in. If you want to modify the source code, you can add a condition after
is_user_logged_in()
like! current_user_can( 'administrator' )
to check if the user is administrator, the form still show up.if ( is_user_logged_in() && ! $this->is_processed() && ! current_user_can( 'administrator' ) ) { esc_html_e( 'You are already logged in.', 'mb-user-profile' ); return false; }
Hope that helps.
April 22, 2020 at 9:17 PM #19223Content Pilot
ParticipantHi Long,
I must admit that this is a very bad suggestion. You are telling me to add custom code to a plugin that you maintain and send out updates to. What happens when you push out another update? Not update our plugin or update the plugin and go back in by hand to add our custom code. Neither is a good solution.
I am happy to send over some code via a pull request but this repo is private. My BitBucket username is [email protected]
I suggest another shortcode attribute be added after line 46 in src/Shortcodes/Register.php
'hide_form' => is_user_logged_in()
And then replace
is_user_logged_in()
in src/Forms/Register.php on line 6 with$this->config['hide_form']
And in your shortcode parameters, you can have:
[mb_user_profile_register hide_form="false"]
This is only a start. Even with these changes, I do not see the form. I don't understand enough about the
has_privilege
method to adjust it to show the form.Can you all add this code and take it to the finish line?
Thanks for your help.
April 22, 2020 at 10:22 PM #19225Long Nguyen
ModeratorHi,
Thank you, I'm going to open an issue for the developer team to support this option for the register form.
Have a nice day 🙂
April 27, 2020 at 9:21 PM #19309Content Pilot
ParticipantHi Long, has there been any progress on adding this functionality.
Thanks in advance for the effort.
April 28, 2020 at 2:00 PM #19329Long Nguyen
ModeratorHi,
A new update has been released, we've added a new option
show_if_user_can
lets the form still shows the current user has a proper capability. This option is also updated in the documentation, please update the extension and check it out.April 28, 2020 at 9:58 PM #19344Content Pilot
ParticipantLong!
Thank you for moving quickly on this.
Exactly what I needed.
Works great.
Please close this ticket.
-
AuthorPosts
- You must be logged in to reply to this topic.