New answers tagged

0

It is used to update the status of a user in the database. Used in core to mark a user as spam or "ham" (not spam) on multisite installs. Status 0 is Ham Status 1 is Spam Again, this will not work on single site installs. https://codex.wordpress.org/Function_Reference/update_user_status#Mark_a_User_as_Spam


0

Sumup: Create a new post & save the search info as post meta-data, then reference it later by the post-id. Create custom post type Learn to Save post meta Use wp_insert_post to save post & meta when search saved Output in templates using conventional loops This gives us a backend solution, that could tie-in to the data you've mentioned saving, ...


0

add_shortcode( 'show_total_listing_price', 'show_total_listing_price' ); function show_total_listing_price ( $atts ) { global $post; $args = array( 'author' => get_current_user_id(), 'post_type' => 'POST_TYPE_GOES_HERE', 'posts_per_page' => -1, 'post_status' => 'publish', ); $query = new WP_Query( $args ); ...


0

This is how to get an array of all the existing user roles, and the capabilities for each role, in WordPress. If you don’t want to print it to the screen, omit the last line. The $roles variable on line 2 will hold the array of users and capabilities so that you can use it however you need to. See below for an example of the returned array. global $wp_roles;...


0

I suggest the Export Users With Meta plugin. It's free, it exports to CSV, and it allows you to select the fields you want to export: PS: I am the author of this plugin, but I created it after I have found this page but found no answer (the answer suggests a plugin that was closed due to security issues).


0

Using PHPCS with WordPress Rules may help you find the issues. https://github.com/WordPress/WordPress-Coding-Standards


1

if you want to use multiple users, if you will add usernames comma separated in custom field. try below code. function user_avatar() { $user = ""; $names = get_post_meta( get_the_ID(), 'user_name', true ); $user_names = array_map('trim', explode(',', $names)); if(!empty($user_names)) { foreach ($user_names as $key => $...


1

Although you could create another class of users, I'd just do the following: Change their password to something really strong and random Change their email address to an invalid value (or maybe a variation of yours) so they can't do a password reset. Maybe change their description/info to show that they are a 'past employee' or whatever generic/polite term ...


-1

WPBeginner has an article describing use of the "User Blocker". It sounds like just what you need. Good luck!


2

As @butlerblog reply stated, you should not use current_user_can to check against a role This notice is specifically added in the PHP documentation of has_cap function which is called by current_user_can While checking against a role in place of a capability is supported in part, this practice is discouraged as it may produce unreliable results. The ...


1

"Add Role" isn't an option in WordPress, and never has been. If you want to add a role you'll need a plugin like User Role Editor or Members. If you want to add a role with code, you can do this with the add_role() function: add_role( 'member', 'Member', [ 'edit_posts' => true, ] ); Just be aware that roles are persistent, so ...


0

If you're using ACF you can also attach custom fields to users. You can attach them by using the Location Rules (the ones in the 'User' subgroup), see Creating custom user profile pages with ACF You could add a single relational → post object field in a field group, Filter by Post Type → Lesson. Then you could use a front-end form which you can pre-...


Top 50 recent answers are included