spiceyux

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • in reply to: Forced site log in #1481104
    spiceyux
    Participant

    Thanks Victor,

    I ended up doing something similar. I wasn’t aware of the wp_safe_redirect(). (My WP skills are a bit rusty).
    One thing to add that I did:

    
    function tribe_ce_login_redirect( $post_id ) {
    	global $wp;
    	$current_url = home_url(add_query_arg(array(),$wp->request));
     	header("Location: /wp-login.php?cestate=required&redirect_to=" . urlencode($current_url) );
    	return;
    }
    add_action( 'tribe_community_before_login_form', 'tribe_ce_login_redirect' );
    
    function the_tribe_ce_login_message( $message ) {
        $tribe_ce_login_messaging = htmlspecialchars($_GET["cestate"]);
    	$cemessage;
    	if(!empty($tribe_ce_login_messaging)){
    		if($tribe_ce_login_messaging='required'){
    			$cemessage = 'Events require an account to submit or edit.';
    		}
    		return '<p class="message">' . $cemessage . '</p>';
    	}
    	return;
    }
    add_filter( 'login_message', 'the_tribe_ce_login_message' );
    

    I grabbed the current url so that, after login, it would redirect back to the originating url.
    Also, passing a query string param so I can message on the native login for that, “Events require an account.”

    I’ll make some updates to leverage the wp_safe_redirect() but wanted to share in case it helps anyone in the future.

    • This reply was modified 8 years, 1 month ago by spiceyux.
    • This reply was modified 8 years, 1 month ago by spiceyux.
Viewing 1 post (of 1 total)