• Resolved simplarity

    (@simplarity)


    Hi,

    How do I add the message that is displayed while the user is pending admin approval to the homepage, for example? For example, on the profile page – after registration but before approval, the message that appears as the entry header is: Thanks for registering! Your account will be approved shortly. After you’re approved…”. I want to show that on the homepage or all non-BP pages.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Michael Beckwith

    (@tw2113)

    The BenchPresser

    Hi @simplarity

    We output that with the following function and action hooks:

    
    function bp_registration_options_bp_after_activate_content() {
    	$user      = get_current_user_id();
    	$user_info = get_userdata( $user );
    	$moderate  = get_option( 'bprwg_moderate' );
    
    	if ( ! $user_info instanceof WP_User ) {
    		return;
    	}
    
    	$activate_screen = ( false === strpos( $_SERVER['REQUEST_URI'], 'activate' ) ) ? false : true;
    	if ( $activate_screen || bp_registration_get_moderation_status( $user ) ) {
    		if ( $moderate ) {
    			$activate_message = stripslashes( get_option( 'bprwg_activate_message' ) );
    			$activate_message = str_replace( '[username]', $user_info->data->user_login, $activate_message );
    			echo '<div id="message" class="error"><p>' . $activate_message . '</p></div>';
    		}
    	}
    }
    add_filter( 'bp_after_activate_content', 'bp_registration_options_bp_after_activate_content' );
    add_filter( 'bp_before_member_header', 'bp_registration_options_bp_after_activate_content' );
    

    In as short as I can manage, we grab the current user, grab some of their info, grab our moderate status to see if we should output. We then check if we’re on the right screen, and if the user is presently moderated. If yes to all, we fetch the activate message and change out our shortcode placeholders with their info and echo it out.

    For your usage, you’d want to remove the activate screen check. Perhaps something like below:

    function simplarity_bp_registration_options_bp_after_activate_content() {
    	$user      = get_current_user_id();
    	$user_info = get_userdata( $user );
    	$moderate  = get_option( 'bprwg_moderate' );
    
    	if ( ! $user_info instanceof WP_User ) {
    		return;
    	}
    
    	if ( bp_registration_get_moderation_status( $user ) ) {
    		if ( $moderate ) {
    			$activate_message = stripslashes( get_option( 'bprwg_activate_message' ) );
    			$activate_message = str_replace( '[username]', $user_info->data->user_login, $activate_message );
    			echo '<div id="message" class="error"><p>' . $activate_message . '</p></div>';
    		}
    	}
    }
    

    You could invoke that wherever you want, or attach it to some other action hooks that you have available.

    Let me know if you have any questions.

    Thread Starter simplarity

    (@simplarity)

    Thanks, Michael! I’ll give this a try. I appreciate the quick response and your efforts in supporting the plugin.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add approval pending to other pages’ is closed to new replies.