|
Membership Site – Update Status of User Posts when User Role is Changed
Started by: jonB-5
in: Toolset Professional Support
Quick solution available
Problem: I would like to programmatically change the post status of all posts by the current User in a PHP hook I have set up to handle User role changes.
Solution: You can use the WordPress get_posts function to query all the author's posts, then update each of the posts as needed with wp_update_post. Here is a basic example:
...
$user->set_role( 'tsn_bronze' );
// get all the published Voyage posts by the current user
$args = array(
'post_type' => 'voyage',
'post_status' => 'publish',
'author' => $user_id,
'posts_per_page' => -1);
$posts_array = get_posts($args);
// loop over those posts and update each one to status "pending"
foreach ($posts_array as $the_post) {
$update_post = array(
'ID' => $the_post->ID,
'post_status' => 'pending'
);
wp_update_post( $update_post );
}
If you want to use the same code to update posts of more than one custom post type, modify the 'post_type' argument to use an array instead of a single string:
$args = array(
'post_type' => array('voyage','deck-event'),
Relevant Documentation:
https://codex.wordpress.org/Template_Tags/get_posts
https://codex.wordpress.org/Function_Reference/wp_update_post
https://codex.wordpress.org/Class_Reference/WP_Query#Type_Parameters
|
|
2 |
3 |
6 years, 9 months ago
jonB-5
|
|
Allow only some categories editing with Types Access
Started by: Franco Calcagni
in: Toolset Professional Support
Quick solution available
|
|
2 |
3 |
6 years, 9 months ago
Franco Calcagni
|
|
Access Control of Field Group Doesn’t Appear to Work
Started by: Richard Jacob
in: Toolset Professional Support
Quick solution available
Problem: I would like to show Authors a read-only CRED field, but show other Users the standard editable field.
Solution:
You can apply inline Access control shortcodes:
[toolset_access role="Author" operator="deny"]
[cred_field field='my-text' post='post' value='' urlparam='' output='bootstrap']
[/toolset_access]
[toolset_access role="Author" operator="allow"]
[cred_field field='my-text' post='post' value='' urlparam='' output='bootstrap' readonly='true']
[/toolset_access]
The readonly attribute only works for text controls, not select fields or checkboxes and so forth. If you want to show the values of those fields, you can use the standard types field shortcode like this:
[toolset_access role="Author" operator="deny"]
[cred_field field='my-checkboxes' post='post' value='' urlparam='' output='bootstrap']
[/toolset_access]
[toolset_access role="Author" operator="allow"]
[types field='my-checkboxes'][/types]
[/toolset_access]
Relevant Documentation: https://toolset.com/documentation/user-guides/access-control-texts-inside-page-content/
|
|
2 |
3 |
6 years, 9 months ago
Richard Jacob
|
|
How to set up automatic Parent-Child connection ?
Started by: yashwantK
in: Toolset Professional Support
Quick solution available
|
|
2 |
3 |
6 years, 9 months ago
yashwantK
|
|
Cred form error when logged in as custom role user with access permissions
Started by: malagaS
in: Toolset Professional Support
|
|
2 |
3 |
6 years, 9 months ago
malagaS
|
|
Can’t display login form to visitors
Started by: Edge
in: Toolset Professional Support
Quick solution available
|
|
2 |
11 |
6 years, 9 months ago
Shane
|
|
Create new user password not working
Started by: Edge
in: Toolset Professional Support
Quick solution available
|
|
2 |
4 |
6 years, 9 months ago
Luo Yang
|
|
Need custom role to edit/create custom post, WooCommerce interference?
Started by: davidM-41
in: Toolset Professional Support
|
|
2 |
6 |
6 years, 9 months ago
davidM-41
|
|
Toolset Access adds #no_privileges to some post edit links for shop_manage role
Started by: Jakob
in: Toolset Professional Support
|
|
2 |
7 |
6 years, 10 months ago
Christian Cox
|
|
Charging Subscription Fee by the Number of Posts
Started by: chrisG1876
in: Toolset Professional Support
|
|
2 |
4 |
6 years, 10 months ago
Minesh
|
|
Access not working correctly
Started by: Seb Gates
in: Toolset Professional Support
|
|
2 |
6 |
6 years, 10 months ago
Luo Yang
|
|
Toolset Access: Editors (role) do not have access to add Posts (not custom)
Started by: Alex
in: Toolset Professional Support
|
|
3 |
19 |
6 years, 11 months ago
Alex
|
|
Custom Role Needs Access to Edit Taxonomies & Taxonomy Fields
Started by: Ed
in: Toolset Professional Support
Quick solution available
Problem:
How to grant Edit permission to a taxonomy "career categories" as a user with a custom Role "HR Manager". This custom Role has the taxonomy "career categories" all items checked but I get the "Cheatin’ uh? Sorry, you are not allowed to edit this item."
Solution:
We are unable to reproduce this issue at the moment. If you see the issue, please feel free to open a new ticket.
Relevant Documentation:
|
|
2 |
7 |
6 years, 11 months ago
Ed
|
|
Select user for WPML-Group not working
Started by: post2
in: Toolset Professional Support
|
|
2 |
9 |
6 years, 11 months ago
Christian Cox
|
|
Toolset Access 2.4.3.2 breaks editing capabilities for custom roles
Started by: joelB-3
in: Toolset Professional Support
|
|
2 |
6 |
6 years, 11 months ago
Luo Yang
|