Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function wpses_385303_change_validate() {
- if (is_user_logged_in()) {
- $user_id = get_current_user_id();
- $metas = array(
- '_nickname_validated',
- '_first_name_validated',
- '_last_name_validated',
- );
- //If the form was posted (ie. the button was clicked) in a previous request
- if (isset($_POST['validate_user'])) {
- if ($_POST['validate_user'] == $user_id) {//A little bit of security
- foreach($metas as $my_meta) {
- update_user_meta( $user_id, $my_meta, 'validated' )
- }
- return "<div class='user_updated'>Updated!</div>";
- }
- }
- }
- //Show the form
- return "<form method='post'>
- <input type='hidden' name='validate_user' value='$user_id' />
- <input type='submit' value='Validate' />
- </form>";
- }
- add_shortcode('change_validate','wpses_385303_change_validate');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement