SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2011
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Redirect user problem before and after registration.

    I made a button for submitting an article : http://www.articlespedia.org and i wish to do the following when i click it:
    If i am not logged in then it should redirect to the following page: http://www.articlespedia.org/author, else should go the http://www.articlespedia.org/wp-admin/post-new.php. How am i going to do this? I am a noob in php.

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,167
    Mentioned
    453 Post(s)
    Tagged
    8 Thread(s)
    Because you are using WordPress, you can use some of its build in functions for this. E.g:

    http://codex.wordpress.org/Function_.../auth_redirect
    http://digwp.com/2011/08/how-to-redi...gged-in-users/
    http://snipplr.com/view/46533/

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2011
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ralph.m View Post
    Because you are using WordPress, you can use some of its build in functions for this. E.g:

    http://codex.wordpress.org/Function_.../auth_redirect
    http://digwp.com/2011/08/how-to-redi...gged-in-users/
    http://snipplr.com/view/46533/
    Thank you ralph for helping me as always, wished i was advance like you, i thought on this, and my little brain came up to this:
    How i wish i would know programming, but i know just some base code. In my mind i would do this:
    <p class="buttonn"><a href="http://www.articlespedia.org/"></a></p> this is the button. After i click it, i believe that this code will enter in action, to do this: if(!is_user_logged_in() && $pagenow != 'wp-login.php') {
    wp_redirect( '/authors', 302 );
    }
    The problem is that i don't know how to write this and if it's possible to write it side by side on the button.
    Sorry for being a noob, still got to learn many things.

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,167
    Mentioned
    453 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by imediazone View Post
    wished i was advance like you ... Sorry for being a noob ...
    Don't worry! I'm a noob too. I'll move this to the WordPress forum, because I'm not familiar with WordPress. (I just Googled what you were trying to do.)

  5. #5
    SitePoint Zealot
    Join Date
    Jan 2011
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ralph.m View Post
    Don't worry! I'm a noob too. I'll move this to the WordPress forum, because I'm not familiar with WordPress. (I just Googled what you were trying to do.)
    Ok, thanks anyway, i posted here because you helped me many times

  6. #6
    SitePoint Zealot
    Join Date
    Jan 2011
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Problem solved. I did not know that when you are logged in, the register page will show the correct message, i needed to add <p class="buttonn"><a href="http://www.articlespedia.org/authors"></a></p> and it does everything automatically.

  7. #7
    SitePoint Zealot
    Join Date
    Jan 2011
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One more thing" When the use is logged in and clicks the button, it sends him the following message "Thank you for registering". Instead of this message i want to be redirected to another page. i located the code, and tried the following:
    if(empty($first_visit)) {
    $message = !empty($atts['message'])?$atts['message']:"Thank you for registering.";
    update_user_meta($user_ID,'first_visit',date('Y-m-d'));
    echo '<div id="message" class="success"><p>'.$message.'</p></div>';
    } else {
    echo "You are already registered for this site."; // instead of this, replaced with wp_redirect( 'http://www.articlespedia.org/wp-admin/post-new.php', 301 ); exit; }
    But it did not work, it stopped the page from working.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •