Home › Forums › Plugin Support › Issue with e-mail verification
- This topic has 5 replies, 2 voices, and was last updated 9 years, 4 months ago by smithandjones.
-
AuthorPosts
-
July 26, 2015 at 11:21 am #7506July 26, 2015 at 11:40 am #7507KhaledMember
Hi,
You can get email verification url by following code and add it to the email.
global $userMeta; $verificationUrl = $userMeta->emailVerificationUrl( $user );
Thanks.
July 26, 2015 at 12:33 pm #7508smithandjonesMemberHi Khaled
That works, thank you. Please help with a follow up;
I need to include a different redirect url (I mean different from the url set in User Meta Data’e-mail verification page’)
So can I modify the code line
$verificationUrl = $userMeta->emailVerificationUrl( $user );
to introduce a different redirect url?Regards
Robert
July 27, 2015 at 6:34 pm #7511smithandjonesMemberHi Khaled
Just to ask if you can help with my last post.
I want to modify the code line $verificationUrl = $userMeta->emailVerificationUrl( $user );
to introduce a different redirect url.When the user verifies their e-mail address, I want to redirect to their first post so the url will be in the form;
$url = get_permalink($post_id);
I need to take the variable $url and use it to replace the default url contained in the $userMeta->emailVerificationUrl( $user );
This is the last piece of my jigsaw to get this function completed so I would appreciate your help.
Kind regards
Robert
July 27, 2015 at 11:54 pm #7515KhaledMemberHi Robert,
If you just use
$url = get_permalink($post_id);
and add $url to your email, user shall get your new url.
However. when user visit this url we need to process our email verification code. To implement this, please have a look on user-meta/controllers/pro/umExecutionPageController.php
executionPage method at line 39, which has been called by line 11.
You can do another approach, as your users get their password by email, so you don’t need to verify their email anymore. You can just activate them on your code.
To do it you can add a tracker to the user inside your createpost4 function.
update_user_meta( $user_id, 'reg_method', 'by_post' );
Then use user_register action hook to activate users instantly.
add_action( 'user_register', 'activateUser', 50 ); function activateUser( $userID ) { $reg_method = get_user_meta( $userID, 'reg_method', true ); if ( $reg_method == 'by_post' ) { update_user_meta( $userID, 'user_meta_user_status', 'active' ); } }
Hope, it will helps.
Thanks.
July 28, 2015 at 8:33 pm #7521smithandjonesMemberHi Khaled
I tried the following code as you suggested;
add_action('cred_save_data', 'createpost4',10,2); function createpost4($post_id, $form_data) { // if a specific form if ($form_data['id']==29756) { $email_address = get_post_meta( $post_id, 'wpcf-guitar-email', $single = true ); if( null == username_exists( $email_address ) ) { // Generate the password and create the user $password = wp_generate_password( 12, false ); $user_id = wp_create_user( $email_address, $password, $email_address ); // Set the nickname wp_update_user( array( 'ID' => $user_id, 'nickname' => $email_address ) ); // Set the role $user = new WP_User( $user_id ); $user->set_role( 'customer' ); wp_update_user( array( 'ID' => $user_id, 'reg_method' => 'by_post' ) ); global $userMeta; // $verificationUrl = $userMeta->emailVerificationUrl( $user ); $url = get_permalink($post_id); // Email the user wp_mail( $email_address, 'Welcome', 'Your Password: ' . $password, 'Click the link to see your first post: ' . $url); } wp_update_post(array('ID'=>$post_id, 'post_author'=>$user_id, 'post_status'=>'publish')); } } add_action( 'user_register', 'activateUser', 50 ); function activateUser( $userID ) { $reg_method = get_user_meta( $userID, 'reg_method', true ); if ( $reg_method == 'by_post' ) { update_user_meta( $userID, 'user_meta_user_status', 'active' ); } }
But the new user is not made active.
Two thoughts I had;
1. Does the user date field ‘reg_method’ have to be created first?
2. In the new add_action( ‘user_register’, ….. How does the function know which user is being referred to?
Could you have another look please and see if you can see the problem.
Regards
Robert
-
AuthorPosts
- You must be logged in to reply to this topic.