Adding a role using Members and Formidable Forms [closed]

You want to use the method WP_User::set_role() https://developer.wordpress.org/reference/classes/wp_user/set_role/ If you want to add the role as an additional role, replace set_role with add_role add_action( ‘frm_after_create_entry’, ‘inactive_to_member’, 20, 2 ); function inactive_to_member($entry_id, $form_id) { if ( $form_id == 21 ) { // form id of the form to copy $user = wp_get_current_user(); //get logged in user … Read more

How to check if a user is in a specific role?

If you only need this for current user current_user_can() accepts both roles and capabilities. UPDATE: Passing a role name to current_user_can() is no longer guaranteed to work correctly (see #22624). Instead, you may wish to check user role: $user = wp_get_current_user(); if ( in_array( ‘author’, (array) $user->roles ) ) { //The user has the “author” … Read more

Allow a user or role to view drafts and previews, but not other admin privileges?

Figured out an easier way. I gave them the edit_other_posts and edit_other_pages role capabilities, and then blocked their access to the admin area using the following: add_action( ‘init’, ‘eri_block_nonadmins_init’ ); function eri_block_nonadmins_init() { $current_url = eri_get_current_url( true, false); if ( (!current_user_can( ‘administrator’ ) && !( defined( ‘DOING_AJAX’ ) && DOING_AJAX )) && (is_admin() || $current_url … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)