Validate user meta and redirect

Here is how I would do it: function save_extra_user_profile_fields( $user_id ) { if (!isset($_POST[‘address’]) || empty($_POST[‘address’])) { // this field was not set or was empty // do your action wp_redirect( home_url() ); // or profile page exit; } else { // field was set and contains a value // do your action update_user_meta( $user_id, … Read more

Creating Custom user type just like custom post

Well, Roles are in many ways custom user types and you can add meta fields specific to roles. For example… function is_my_user_role($id = null) { global $profileuser; if (empty($profile) && !empty($id)) $profileuser = get_user_to_edit($id); return (in_array(‘myrole’,$profileuser->roles)) ? true : false; } function my_user_fields($profileuser) { if (!is_my_user_role()) return false; // HTML for the fields } add_action(‘show_user_profile’, … Read more

Updating User Meta from Custom Post Field Upon Publish Not Working

So the theme I used was not firing add_action( ‘publish_place’, ‘update_package_id’ ); or any of it’s variations e.g. save_post So I created a custom hook in the functions.php file of the theme which got the post id from the url (see $_REQUEST[‘pid’]) here’s what it looked like: function update_package_id() { $postinfo = $_REQUEST[‘pid’]; $post = … Read more

Dynamically Generating User Meta Field

After some help with a PHP developer, it seems the main code above was close but certain changes were made. Here is the code for those interested. In this code, the custom post type is: Course. Change accordingly if needed for your own use. function save_educadme_courses_for_user( $user_id ) { if ( !current_user_can( ‘edit_user’, $user_id ) … Read more