How can I redirect the user to the page they were on when they clicked “Lost Password” using “retrieve_password_message” filter

Figured it out. I just needed to be using $_SERVER[‘HTTP_REFERER’] instead: //Modify password reset message and include redirect to referring page add_filter( ‘retrieve_password_message’, ‘collab_retrieve_password_message’, 10, 4 ); function collab_retrieve_password_message( $message, $key, $user_login, $user_data ) { $site_name = wp_specialchars_decode( get_option( ‘blogname’ ), ENT_QUOTES ); $message = __( ‘Someone has requested a password reset for the following … Read more

Disable Attachment Page Except for Category

The problem is that is_category does not do what you thought it does. is_category( ‘keep’ ) tests that the current page is a category archive for the category keep, it does not check if the current attachment/post is in the keep category. The official WordPress developers docs for is_category start with: Determines whether the query … Read more

Redirecting by role from a button

You could try something like the code below. <?php /** * Use the two lines below if the user_id is not available * via get_current_user_id at this point in code execution. * * $user_id = apply_filters( ‘determine_current_user’, false ); * wp_set_current_user( $user_id ); */ $current_user_id = get_current_user_id(); $user_data = get_userdata( $current_user_id ); $user_roles = $user_data->roles; … Read more

redirect site links form joomla to WordPress

When you migrate your site from Joomla to WordPress, it is essential to ensure that you do not lose the SEO value of your existing site. One of the critical steps in this process is to redirect your old site’s URLs to the corresponding pages on your new site. To redirect your existing site links … Read more

Redirect non-logged in users to a specific page

/* add code in current theme activate in this file functions.php */ add_action( ‘template_redirect’, function() { if( ( !is_page(‘login’) ) ) { if (!is_user_logged_in() ) { wp_redirect( site_url( ‘/login’ ) ); // Example : login page exit(); } } });