show message if user is logged in but does not have participation rights
-
Hi there,
Due to a high number of spambot registrations, any user who registers for the forum initially gets “Spectator” rights. Once I check (usually within 12-24 hours) that they are not spam, I change them to “Participant”.
Some people get annoyed that they cannot post immediately. And I would like to create a popup banner that appears when users login for the first time but cannot post. I am capable of the JS and the CSS, but not quite the PHP.Basically, I want to enqueue a JS file if the user is a “spectator” and is “logged in”.
Could you please advise how to complete my function (hopefully just the commented parts), which will go in the functions.php file, and what
add_action
arguments should be applied if I am wrong?function forum_user_is_spectator(){ if ( is_bbpress() && is_user_logged_in() ) { //$User_ID = get user ID //$Spectator = find out if User Has Spectator rights if ($Spectator){ wp_enqueue_script( 'spectator-js', get_template_directory_uri() . '/js/spectator.js', array(), false, true); } } }
add_action('wp_enqueue_scripts', 'forum_user_is_spectator');
thx in advance
- You must be logged in to reply to this topic.