Could you please correct the code is_admin()

What is a moderator? A custom user role? If yes, then: add_action( ‘init’, ‘blockusers_init’ ); function blockusers_init() { if ( is_admin() && (!current_user_can( ‘administrator’ ) || !current_user_can( ‘moderator’ ) ) && ! ( defined( ‘DOING_AJAX’ ) && DOING_AJAX ) ) { wp_redirect( ‘http://madeeasy-online.com/zhile-2/dobavit-obyavlenie/’, 302); exit; } }

uninstall a theme programmaticlly

The limit of the child theme is not a border from WordPress, maybe your webspace. If you remove the directory of a child theme, include all files, if is deleted. For the delete of the folder use rmdir(). The method rmdir() is part of the classes that extend WP_Filesystem_Base, like WP_Filesystem_Direct and accordingly the rmdir() … Read more

Restoring pages in wordpress

Probably the best solution is to restore your WP database, if you have backup. If not, ask your hosting provider to do that, if you are on shared on VPS hosting, they should make full backup of your account and database every 1-2 days (even without your knowing). Because you exceeded disk quota, maybe something … Read more

Get title from IDs in a string

get_the_title takes an int, not an array of ints, and therefore returns a string, not an array of strings. So just break that bit out into a loop: $titles=””; foreach ($act_name as $act_name_item) { $titles .= ($titles ? ‘,’ : ”) . get_the_title ($act_name_item); }

How to include a hyperlink in the body text of a custom password protected form?

I assume the code you added to functions.php is a filter for ‘the_password_form’, where you’ve got something like: function my_protected_post_form () { $myCustomizedFormCode=”<form action=….” return $myCustomizedFormCode; } add_filter (‘the_password_form’, ‘my_protected_post_form’); So where you have the instructions to the user in that custom form code string, you just need some simple HTML to provide the link … Read more

How to automatically add custom classes to headings in content area

Yes, there are a couple of ways you can do this. One is by creating a filter in the functions.php file, like what is done here: https://stackoverflow.com/questions/10468697/how-to-add-a-class-to-a-html-element-using-filters-in-wordpress The other would be to use Javascript/jQuery to add classes to all the headers post load. Using the php variant would be more elegant, though.

How to assign results to variables?

Best luck while you learn. $fivesdrafts = $wpdb->get_results( ” SELECT ID, post_title FROM $wpdb->posts WHERE post_status=”draft” AND post_author = 5 ” ); foreach ( $fivesdrafts as $fivesdraft ) { echo $fivesdraft->post_title; } This example has been sponsored by WordPress codex. In your case $wpdb->get_results( Should become like: $variable_to_print = $wpdb->get_results(

Change the second role depending on the first

Because you are operating on the current (logged in) user – you need to accept parameters in your callback so that you can operate on the user whose role is being set: rb_update_user_role( $user_id, $role ) { // error_log( “Setting user $user_id to role $role” ); if ( $role !== ‘s2member_level0’ && $role !== ‘s2member_level1’ … Read more