Custom Fields
Re-Envisioned
Support MB User Profile mb_user_profile_register Form does not show if already logged in

  • Creator
    Topic
  • #19198
    Resolved Content Pilot
    Participant

    Hi, 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.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Author
    Replies
  • #19218
    Long Nguyen
    Moderator

    Hi,

    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.

    #19223
    Content Pilot
    Participant

    Hi 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 clayton.collie@contentpilot.com

    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.

    #19225
    Long Nguyen
    Moderator

    Hi,

    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 🙂

    #19309
    Content Pilot
    Participant

    Hi Long, has there been any progress on adding this functionality.

    Thanks in advance for the effort.

    #19329
    Long Nguyen
    Moderator

    Hi,

    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.

    #19344
    Content Pilot
    Participant

    Long!

    Thank you for moving quickly on this.

    Exactly what I needed.

    Works great.

    Please close this ticket.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.