Ask the community

This is a community support forum where you can ask
questions and interact with other PremiumPress Customers.

Need to redirect default login to advertisement page


  • vanessa
    Newbie 14 points
    January 23, 2018 at 4:02 pm

    Hi. I try to add the Membership shortcode but it does not work. It gives error. says something like: Warning: illegal string offset in lines 903 and also line 904. Do not know what they mean.

    I want users to login or register prior to look at advertising page. can you please help me on how to add a redirect to default login to a page. thank you

  • JamesD
    JamesD
    Super Guru 1,345 points
    January 23, 2018 at 10:11 pm

    Hello vanessa,

    Try adding this to your ‘functions.php’ file under “ADD YOUR CUSTOM CODE BELOW THIS LINE”:

    	add_action('get_header', 'ad_preauth_check');
    	function ad_preauth_check() {
    	    global $post;
    	    if(isset($post->post_name)) {}
    	       $slug = $post->post_name;
    	    if ($slug == 'pre-log-ad' && !is_user_logged_in()) {
    	        auth_redirect();
    	    }
    	}

    Note: Replace the “pre-log-ad” with the slug name of your ad page.

    This reply was awarded the best answer by the topic poster.

  • vanessa
    Newbie 14 points
    January 24, 2018 at 3:52 am

    thank you!!!

  • JamesD
    JamesD
    Super Guru 1,345 points
    January 24, 2018 at 3:57 am

    My pleasure @vanessa, hope it helps.

  • Marie
    Marie
    Super Guru 1,759 points
    January 24, 2018 at 4:10 am

    thanks for sharing James :)

  • Garry
    Garry
    Newbie 11 points
    October 1, 2018 at 1:04 pm

    Hi JamesD

    I have a similar issue

    When a member logs into my live site they are being redirected to https://www.reikihealingassociation.com/wp-admin and they see an error message (Oops! You do not have sufficient permissions to access this page.)

    This is really confusing for them and unless they are smart enough to hit the back button and look to the top left corner of the page and see that they have logged in successfully, they are getting quite frustrated and angry.

    I would like them to be redirected to ideally the my account page or at least the home page

    I have tried adding the code you suggested above, but it doesn’t work, do you have any other suggestions?

    add_action(‘get_header’, ‘ad_preauth_check’);
    function ad_preauth_check() {
    global $post;
    if(isset($post->post_name)) {}
    $slug = $post->post_name;
    if ($slug == ‘my-account’ && !is_user_logged_in()) {
    auth_redirect();
    }
    }

    Appreciate any help to resolve this issue

    Attachments:
    You must be logged in to view attached files.
  • Marie
    Marie
    Super Guru 1,759 points
    October 2, 2018 at 10:07 am

    hi garry,

    if your users redirects to wp-admin, that means your newly registered user’ user role is NOT set to Subscriber.

    Make sure you set the user role to subscriber via WordPress dashboard > Settings > General

  • Garry
    Garry
    Newbie 11 points
    October 2, 2018 at 11:11 am

    Thanks Marie

    Issue resolved.

    Regards

    Garry

  • Alex Morgan
    Alex Morgan
    Super Guru 1,110 points
    October 2, 2018 at 11:19 am

    Thanks for sharing Marie :)

Viewing 9 posts - 1 through 9 (of 9 total)