Support » Plugin: Ultimate Member – User Profile, User Registration, Login & Membership Plugin » How to approve automatically after registration?

  • Resolved neueweide

    (@neueweide)


    I’m trying to hook into the um_registration_complete to check the eMail Domain of a User registering. If he has a defined Domain in his Mail i want to approve him automatically.
    Let’s say all Users with a Mail Address ending with @my-domain.com should be approved automatically. All others should be approved manually by an Administrator.

    i always ended up with a critical error… in my browser

    here a very basic approuch i tried in my functions.php:

    um_fetch_user( 53 );
    echo um_user('display_name');
    UM()->user()->set_role( 'um_my-custom-role' );
    UM()->user()->approve();

    the echo line is showing correctly the display_name of the user with the ID: 53
    But the next two lines causes an critical error.

    please give me some advice how to fix this.
    best
    robert

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @neueweide

    What’s the error that displays on the page?

    Regards,

    missveronica

    (@missveronicatv)

    Thread Starter neueweide

    (@neueweide)

    Hi @champsupertramp

    seems it works today like a charm…
    don’t know what caused the problem (caching, etc…) yesterday .)
    I didn’t change anything in the code.

    thank you for your time and regards
    robert

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @neueweide

    Thanks for letting us know. I’m marking this as resolved now.

    Regards,

    Thread Starter neueweide

    (@neueweide)

    One moment please 🙂

    now i’m fetching same issue but not with the approve(); line but with the set_role(); line ?!

    um_fetch_user( $user_id );
    UM()->user()->approve();
    UM()->user()->set_role( $right_level_auto_activation_role );

    I got this error messge:

    PHP Fatal error: Uncaught Error: Call to undefined method um\core\User::set_role() in /home/wp/disk/wordpress/wp-content/themes/...

    Have you any ideas what’s the reason, seems like the method set_role() is unknown? The UM()->user()->approve(); works fine.

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