wp_insert_user role not working

$WP_array = array ( ‘user_login’ => $username, ‘user_email’ => $email, ‘user_pass’ => $password, ‘user_url’ => $website, ‘first_name’ => $first_name, ‘last_name’ => $last_name, ‘nickname’ => $nickname, ‘description’ => $bio, ) ; $id = wp_insert_user( $WP_array ) ; wp_update_user( array (‘ID’ => $id, ‘role’ => ‘editor’) ) ; Since you are looking for working solutions, this one … Read more

Encode text string being appended as query to URL [closed]

To encode the URL, you could use the PHP urlencode( $url ) function or use the WordPress urlencode_deep( $array | $str ); function. add_shortcode( ‘dynamic_contact_button’, ‘button_product_page’ ); function button_product_page() { global $product; return urlencode( “https://wordpress.stackexchange.com/contact-form/?products=Product:%20” .$product->get_title(). “&#contact_form” ); } links: WordPress – urlencode_deep urlencode

Transaction when using WP functions rather than vanilla SQL?

There is no functions in wordpress to handle transactions but you can easily use the $wpdb object to make a simple query to achieve this. The following function will start a transaction and then insert a new user into the database and finally rollback the current transaction. In order to make the transaction permanent you … Read more

Apply class to every paragraph that holds image?

You could use jQuery if you don’t mind to rely on JavaScript for adding the class. $(document).ready(function() { $(‘p:has(img)’).addClass(‘image’); }); Update: the .has() method is probably faster, see this jsperf.com test. $(document).ready(function() { $(‘p’).has(‘img’).addClass(‘image’); });

Using register_activation_hook in classes

Having reread your question, I think I see the issue, and it stems from a misunderstanding of how register_activation_hook works, combined with some confusion over how you’re bootstrapping your code and what it means to bootstrap Part 1: register_activation_hook This function takes 2 parameters: register_activation_hook( string $file, callable $function ) The first parameter, $file is … Read more

Make Google index the entire post if it is separated into several pages

The basic problem for a script solution is: rel_canonical does not offer any useful filter. So we have to replace that function: remove_action( ‘wp_head’, ‘rel_canonical’ ); add_action( ‘wp_head’, ‘t5_canonical_subpages’ ); The next problem: $GLOBALS[‘numpages’] is empty before setup_postdata(). We could call that function already here, but it might have side-effects. Here is a solution that … Read more

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş