Different fields in My Profile page depending on user role

I’ll post whole code which have to be in functions.php it’s legit WP valid code, how it should be done 🙂 This should work, of course you have to put your role name in switch. UPDATED FOR PERFORMANCE: add_action( ‘show_user_profile’, ‘user_fields_for_admin’, 10); add_action( ‘edit_user_profile’, ‘user_fields_for_admin’, 10); function user_fields_for_admin( $user ){ switch ($user->roles[0]) { case ‘SOME … Read more

How to filter get_avatar?

The Original Poster was missing the pair priority, parameters when declaring the filter hook: add_filter( ‘get_avatar’, array( $this, ‘get_avatar’ ), 10, 5 ); Being 5 all the parameters the callback function can use: public function get_avatar( $avatar, $id_or_email, $size, $default, $alt ) { return $avatar; }

Capability to edit own posts and not others

The capabilities that you are trying to restrict are delete_others_posts edit_others_posts Apart from Super Admin and Administrator, the only Role that have these permission is Editor. So, removing these capabilities from Editor should accomplish this. /** * Remove capabilities from editors. * * Call the function when your plugin/theme is activated. */ function wpcodex_set_capabilities() { … Read more

How to archive a wordpress site (make it read only)

Assuming you have shell access, or access to any Linux/Unix box, you could use wget to download the entire site to static html files: wget –recursive –no-clobber –page-requisites –html-extension –domains domain.com http://domain.com Then either upload or move these files to your web root (after backing up and removing your WP installation). I imagine it’s also … Read more

Admin Bar (Toolbar) not showing on custom PHP file that loads WordPress

If WordPress is loaded from outside of the main WordPress files using a separate PHP script that includes wp-load.php then the /template-loader.php file will not be loaded and therefore the template_redirect action will not be triggered. This is important because template_redirect is how the Toolbar is initialized on the front end. Taking a look at … Read more

How do I set up a webhook?

You are using self-hosted WordPress, which sometimes referred to as WordPress.org. Calling remote hook is still a possibility there, but unless your e-commerce solution supports it, you may need to add a custom code. Option – find a plugin There are some plugins which will post data to external URL when certain event happens, say, … Read more

Can I disable the auto complete?

I have a solution I tested, and it works. The autocomplete for the tags is currently done via an ajax request to the file admin-ajax.php. The solution I would suggest is to block the processing of the request so that it does not return any result. I would do : function no_tag_suggest() { if( DOING_AJAX … Read more