This topic has 8 replies, 3 voices, and was last updated 7 years by Radu.

  • Author
  • #158479
     ThrewTheNevR
    Participant

     I was wondering if there is a php code to display a registered users email on the confirm email page.

    Default one reads

    You have successfully created your account! To begin using this site you will need to activate your account via the email we have just sent to your address.

    I’d like to have (your address) actually show the email that was registered.

    Any documentation will help.

    I tried the code below but it didn’t work,did I miss something?

    <?php global $user_email;
    get_currentuserinfo();

    echo $email address is: ” . $user_email;
    ?>

    It appears to work only if I have them login automatically right after registration but the way I have my site set up is they get redirected to the activity feed after logging in and I really don’t want to change that.

    #158495
     Laura
    Moderator

    Hello, will assign the ticket to a higher support level who can help and advise you in your query.
    Thanks! ?

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

    #158598
     ThrewTheNevR
    Participant

    Just a quick update.
    I’ve been searching nonstop threw documentation/Codex and I came up with this code,

    COPY CODE
    global $wpdb;
    
    /* lets retrieve the email  of  users who signed up  $wpdb */
    function get_user_by( ‘email’,‘null’ ) 
    $user_email  = $wpdb->wpjm_signups (‘user_email’);
    if ($signups) {
        echo "sent to " . $user_email ;
    } else {
        echo "email not listed.";
    }
    //Creating a shortcode to display signup email
    add_shortcode( 'user_email');

    I placed it in my themes functions.php file but had to delete it due to the 500 error.

    Am I on the right track?

    #158858
     Radu
    Moderator

    Hi,

    We don;t have a plug and play soltion for this and also no plugin found that can do this.

    But you can try to print_r the superglobal variable $_POST

    print($_POST);

    To see if in the activation page it’s passed some data, if this will not work you will need a developer to achieve what you need
    Cheers
    R.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #159318
     ThrewTheNevR
    Participant

    I appreciate the reply but that didn’t work for me,
    I found a way though but it broke a few things.

    I added this to KleoChild function.php

    // auto log in a user who has just signed up
    function wp_auto_login_new_user( $user_id ) {
    wp_set_current_user( $user_id );
    wp_set_auth_cookie( $user_id, false, is_ssl() );
    }
    add_action( ‘user_register’, ‘wp_auto_login_new_user’ );

    And In kleo/buddypress/member inside register.php
    I added this right under
    ((((<?php if ( bp_registration_needs_activation() ) : ?>)))) located on line 307 for me.I replaced the code originally under that line there with

    <?php
    $current_user = wp_get_current_user();

    /**
    * @example Safe usage: $current_user = wp_get_current_user();
    * if ( !($current_user instanceof WP_User) )
    * return;
    */
    echo “<p> Thanks for registering, <b>$current_user->user_login. </b></p>” ;
    echo “<p> You have successfully created your account! <br />To begin using this site you will need to activate your
    account via the email we have just sent to <b>$current_user->user_email . </b></p>” ;
    ?>

    Now with that being added I got my page to look exactly how I wanted it to. But the problem now is since I have custom redirects set to https://mywebsite/activity from the Kleo theme options “login popup and home page redirect “,check email page if it is refreshed a postdata popup error shows up and if u click continue it will redirect to the activity page without activating the account first from the email that was sent.

    I added this to the register.php

    //If there’s something in the POST, move it to the session and then redirect right back to where we are
    if ($_POST) {
    $_SESSION[‘POST’]=$_POST;
    redirect($_SERVER[“REQUEST_URI”]);
    }

    //If there’s something in the SESSION POST, move it back to the POST and clear the SESSION POST
    if ($_SESSION[‘POST’]) {
    $_POST=$_SESSION[‘POST’];
    unset($_SESSION[‘POST’]);
    }

    But that didn’t work. If user registers on homepage then Redirects to >please check email for activation page if that page is refreshed the postdata pop up shows still. How can I have this page stay the same if a user refresh this page before activating their account?

    The other issue is now if a user activates threw the email the page that says activation has been completed please log in using the credentials you provided no longer shows up. They are just taken strait to the activity page.
    I still needed that page to show up yet having them logged in still so I can have the user click on more added code (next button) so they can be redirected to a custom page to upload their avatars before being redirected to the activity page.

    So in a nutshell,
    How do I keep the check email for activation page redirect to that same page if the Page is refreshed while registered user is still logged in. Just for that page.instead of redirecting to activity page before activation?

    And how do I get the activation has been completed page to show up again? Since it just redirects to activity page.

    #159329
     ThrewTheNevR
    Participant

    I’m actually thinking would it be easier if I just added a redirect in wp-login.php if users log in they are redirected to the activity page?

    Because if I do that wouldnt it eliminate all the issues I had. Other than the postdata issue on the email confirmation page but In that case it would redirect to Homepage or default registration page and I wouldn’t mind that.

    #159483
     Radu
    Moderator

    Hi,

    Did you have tried to use the native buddyPress emailing templates ?

    Wp-admin -> emails ->

    For your code
    You can try to activate manually accounts with this kind of function that updates the user status in database

    <?php add_user_meta( $user_id, 'user_status', '0' ); ?>

    Then you can redirect with this function from example

    COPY CODE
    
    function sq7_rdu_redirect( $redirect_to, $request, $user ) {
    $redirect_to = 'http://google.com/my-super-link/';
    return $redirect_to;
    }
    add_filter('login_redirect', 'sq7_rdu_redirect');

    links : https://wordpress.stackexchange.com/questions/117522/send-user-activation-email-when-programmatically-creating-user

    Cheers
    R.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #159605
     ThrewTheNevR
    Participant

    Mk so I figured it out,
    The code is

    COPY CODE
    Thanks for registering,<b><?php echo $_POST["signup_username"]; ?></b> You have successfully created your account! To begin using this site you will need to activate your 
       account via the email we have just sent to <b><?php echo $_POST  ["signup_email"] ;?><b>
    

    The reason it didn’t work before was I had the arrays wrong. I used print_r to double check and now have it working.

    With that being said I have taken out my function that automatically logs in new registered users and also took out my $get current_user code.
    Everything is working as it should.
    Only if I double checked 2 weeks ago would of saved me a headach.but I’m still new and learning php and with so much documentation things easily over looked.

    Type guys.

    #159652
     Radu
    Moderator

    Great

    Good luck with your project

    Cheers
    R.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 9 posts - 1 through 9 (of 9 total)

The forum ‘General questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?