Hi @a5345534,
Thanks for using myCred please add this code in your functions.php file.
add_action('mycred_init', 'promote_user_role');
function promote_user_role() {
$user_id = get_current_user_id();
$ref_sums = mycred_get_users_reference_sum( $user_id );
// Check if user has gained points for published content
if ( ! empty( $ref_sums ) && array_key_exists( 'publishing_content', $ref_sums ) ) {
// If they have, check if it's over 1000 points and that they are not yet "Authors"
if ( $ref_sums['publishing_content'] >= 1000 && ! user_can( $user_id, 'publish_posts' ) )
wp_update_user( array(
'ID' => $user_id,
'role' => 'author'
) );
}
}
thanks for your help
i allready add this code in this functions.php file.
bactopur.com/public_html/wp-content/themes/oceanwp/functions.php
Do I still need to do anything?
Hi @a5345534,
Please make sure to enable this hook after adding the code as shared in the screenshot below.
https://drive.google.com/file/u/1/d/1UGHabwZgxKSeWEESrO0jEZnEwd_MqCj_/view?usp=sharing
WOW,i am sure it worked.
But I do n’t want to limit it to publishing_content
I want the function to refer to total balance
How should I modify it?
Hi,
It’s great to hear that your issue is resolved we would appreciate a kind and honest review.
Thanks!