1

When people register on my wordpress website using a civicrm profile, they get logged in automatically. As I first need an Administrator to approve the user, I would like users not to be logged in after registration is complete.

Is there a parameter I have missed or would I need to use a filter or whatever ?

2

CiviCRM relies on CMS(i.e WP) settings when creating users. By default WP doesn't provide any such settings so you may need to install some plugin which needs admin approval for newly created user. Probably something like User Approve plugin.

  • Thanks, actually I am using this plugin but the user gets an error message telling him he/she has no access to the page when he/she registers. "We can't load the requested web page. This page requires cookies to be enabled in your browser settings. Please check this setting and enable cookies (if they are not enabled)" – Tuto Jun 25 at 19:42
2

You're running into the effects of this code which automatically logs the user in. Unfortunately there's no way to override this code at the moment - except to override the class file itself by putting an edited copy in your custom PHP folder like this and remove those lines.

A couple of alternative approaches are to:

2

Thanks a lot guys. You got me on the right way and I looked for a wordpress solution instead of a civi one. I just added the following bits of code to my function.php file (in the child theme) to get disconnected and immediately redirected to a specific page (otherwise I was getting a civicrm error telling me I had no access to the page it was redirecting me to) :

/**
 * WordPress function to prevent autologin
 */
function user_autologout(){
            wp_logout();         
        }
add_action('user_register','user_autologout');

/**
 * WordPress function for redirecting users on logout. If user comes from registration page, they are directed to a page telling them that their membership request is pending. 
 */


function auto_redirect_after_logout(){
    if (strpos($_SERVER['HTTP_REFERER'], 'inscription') !== false){
    wp_redirect( home_url().'/pending_registration/' );
    exit(); 
    }
    else{
    wp_redirect( home_url() );
    exit();
    }
}
add_action('wp_logout','auto_redirect_after_logout');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.