Need to redirect default login to advertisement page

WordPress Business Themes Forums Responsive Themes Coupon Theme Need to redirect default login to advertisement page

Discontinued - The forum content is out of date. For theme support please use our support desk here.

Need to redirect default login to advertisement page

January 23, 2018
 vanessa

  • vanessa
    Newbie 14 points

    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

    January 23, 2018 at 4:02 pm
  • JamesD
    JamesD
    Super Guru 1,351 points

    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.

    January 23, 2018 at 10:11 pm
    This reply was awarded the best answer by the topic poster.

  • vanessa
    Newbie 14 points

    thank you!!!

    January 24, 2018 at 3:52 am
  • JamesD
    JamesD
    Super Guru 1,351 points

    My pleasure @vanessa, hope it helps.

    January 24, 2018 at 3:57 am
  • Marie
    Marie
    Super Guru 1,747 points

    thanks for sharing James :)

    January 24, 2018 at 4:10 am
  • Garry
    Garry
    Newbie 11 points

    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.
    October 1, 2018 at 1:04 pm
  • Marie
    Marie
    Super Guru 1,747 points

    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

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

    Thanks Marie

    Issue resolved.

    Regards

    Garry

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

    Thanks for sharing Marie :)

    October 2, 2018 at 11:19 am
Viewing 9 posts - 1 through 9 (of 9 total)

Didn't find what you were after?

Chat with us now

or contact our support team