Hide custom fields by user’s role

You can use the current_user_can() function to test the current user’s role. I would also recommend making the custom field protected by default and allowing access only to the proper users. In theory, something like this should work: function my_exclude_custom_fields( $protected, $meta_key) { if ( in_array( $meta_key, array( ’email’, ‘text’ ) ) ) { if … Read more

How do you make a custom post type invisible for subscribers

register_post_type() accepts a parameter capabilities in its arguments. See get_post_type_capabilities() for possible values. you can add these settings in your code while registering the custom post type ‘capabilities’ => array( ‘edit_post’ => ‘update_core’, ‘read_post’ => ‘update_core’, ‘delete_post’ => ‘update_core’, ‘edit_posts’ => ‘update_core’, ‘edit_others_posts’ => ‘update_core’, ‘delete_posts’ => ‘update_core’, ‘publish_posts’ => ‘update_core’, ‘read_private_posts’ => ‘update_core’ ),

Remove all video attachment, both files and post/postmeta from database?

You call wp_delete_attachment passing $attachmentid which is undefined, so it can’t work… Also the $force_delete variable isn’t defined anywhere in your code. Also there is no point in using normal loop in here – you don’t use template tags in this action, so calling the_post is just a waste of resources… add_action( ‘set_user_role’, function( $user_id, … Read more

Dropdown of user roles that depend on variable

1: $billing_company will return user billing_company whatever it is. 2: In $args you are supposed to put an array of user roles to fetch. If you don’t know user role then you can use global var global $current_user; and $user_roles = $current_user->roles; to get all current user roles, so it would be $args = array( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)