Plugin Author
weDevs
(@wedevs)
@lamedo
If you want to automatically publish posts based on user role, you need to add additional function using action hooks of WP User Frontend plugin.
Reference:
https://docs.wedevs.com/docs/wp-user-frontend-pro/developer-docs/
You can use wpuf_add_post_after_insert & wpuf_edit_post_after_update action to load your function inside that form.
Thank you
Thread Starter
lamedo
(@lamedo)
Sorry, I am pretty much a noob in coding, especially in hoooks.
Could someone help me write the code?
@lamedo you can use the following code inside the theme’s functions.php file. The posts submitted by admin will be published directly.
/**
* Set post status published when the user role is admin
*/
function wpuf_update_admin_post_status( $post_id )
{
if ( current_user_can('administrator') )
{
$current_post = array(
'ID' => $post_id,
'post_status' => 'publish',
);
wp_update_post( $current_post );
}
}
add_action( 'wpuf_add_post_after_insert', 'wpuf_update_admin_post_status' );
add_action( 'wpuf_edit_post_after_update', 'wpuf_update_admin_post_status' );
Thank you
Thread Starter
lamedo
(@lamedo)
Thank you so much! it works!