Hot answers tagged

21

In you PhpMyAdmin query for: (if you have a different database prefix, change that in the query, also change the user_id to yours) SELECT * FROM `wp_usermeta` WHERE `user_id` =1 AND `meta_key` LIKE 'meta-box%' Than delete those values and you will get the original order back. If you only want to change the menu order back for a page than only delete "...


20

I'm going to answer this myself, but it was the very clever @simonwheatley of Code for the People that solved this one for me. Instead of using wp_reset_postdata() or wp_reset_query(), you can use the following: $publication->reset_postdata(); Where $publication is your query object. The working code now looks like: $publication = new WP_Query( array(...


12

Here's one way to add this feature using the following flowline : The admin updates the user option page: -> edit_user_profile_update or personal_options_update hooks activated -> edit_user() function is called -> wp_update_user() function is called within edit_user() -> wp_insert_user() function is called within wp_update_user() ...


9

The "correct" answer doesn't work here because the action 'password_reset' fires before the password is reset. I modified the first answer, before the update, to work. function wpse_lost_password_redirect() { // Check if have submitted $confirm = ( isset($_GET['action'] ) && $_GET['action'] == resetpass ); if( $confirm ) { ...


9

You can intercept this email before it is sent using the phpmailer_init hook. By default, this hook fires before any email is sent. In the function below, $phpmailer will be an instance of PHPMailer, and you can use its methods to remove the default recipient and manipulate the email before it is sent. add_action('phpmailer_init', '...


8

Here is an updated version of the code from @bainternet with the syntax errors corrected, the suggestion by @Val and the key generator from wp-login.php 3.4.2: global $wpdb; $username = trim($_POST['user_login']); $user_exists = false; // First check by username if ( username_exists( $username ) ){ $user_exists = true; $user = get_user_by('login', $...


7

Here is a simple solution. Im hooking into login_headerurl. Maybe there is a better hook for this but it works, Put this in your functions.php: function wpse_lost_password_redirect() { // Check if have submitted $confirm = ( isset($_GET['checkemail'] ) ? $_GET['checkemail'] : '' ); if( $confirm ) { wp_redirect( home_url() ); ...


6

After much research, I finally turned to examining the WordPress core file wp_login.php hoping that WP would show how they do it in a non-obtuse manner. From the information around line 331 (WP 4.6.1), I put together the following code. <?php global $gw_activate_template; extract( $gw_activate_template->result ); $url = is_multisite() ? ...


5

First of all, I think it's possible to use get_posts() in combination with setup_postdata(). With these, you can use the template tags as in a normal WordPress loop. But you can use this function also in your nested loops: # make sure $post is the global in your scope (which should be the case in single.php) global $post; if ( $publication->have_posts() ...


4

There's no need to use them both. You should only use wp_reset_query(), if you modified query with query_posts() (which you should avoid). This function also call wp_reset_postdata() - http://core.trac.wordpress.org/browser/tags/3.4.1/wp-includes/query.php#L95 So it's better to use wp_reset_postdata() after running separate query.


4

Here is a picture explaning how to do it be carful and backup the database befoure any changes are done first here is a link to md5 encoder (youll need it): MD5 Encoder . Hope this helps ;) Cheers, Sagive.


4

You did it correctly! It's the example that's wrong. Sadly almost all examples of queries have this problem Normally putting it after the conditional has no ill effects, but when nesting loops it could cause problems in edge cases. For 99.9% of use cases this isn't an issue. By putting it inside the conditional you've ensured the the postdata is only reset ...


4

wp_reset_postdata() resets the value of the global $post variable to the post property of the main query, which will be whatever post the main query was last on. You would do this if you had used setup_postdata() or $query->the_post() on a custom query. Both of these replace the global $post variable so that functions like the_title() get the correct ...


3

Actually it depends how you create the new user. If you do it from administration - Users - Add New you are right. In 4.3 unfortunatelly you cannot disable sending the notification email. But if you really want to create a new user without the email, there is a way. You can create a small plugin where you'd create a new account by yourself via ...


3

One way to solve this would be to set up your demo site exactly how you want it to reset every day (use a standard username and pass like "admin" and "testpass"), and then dump the database and zip the files. Then, put the zip somewhere on your server. Set up a BASH script that deletes the contents of the current Wordpress directory, drops all the tables ...


3

The following code will reset a WordPress default role to it's default capabilities. Note: these defaults are for WordPress 3.5, any other versions might have different defaults. To be safe, only use this code on WordPress 3.5. Warning This cannot be undone! The role, in it's current state, is removed and recreated with it's default values. /* * example ...


3

Try using a web-based MD5 generator, and then paste the generated MD5 value directly into phpMyAdmin without using phpMyAdmin's MD5 function. When using the generator, choose a simple password, like "temp123" to avoid any potential issues with complexity. Then once you can login to WordPress, use the Admin Panel to change ithe password back to something ...


3

WordPress doesn't add any CSS to your site, at least not by default, other than a little bit for the admin bar. For the most part, all of the CSS is added by your theme or by a plugin, though there might be an exception or two. WordPress functions do generate a lot of ids and classes though, but those shouldn't matter for a CSS reset. A 'reset' normalizes ...


3

The wp_new_user_notification function is pluggable, so you can override it by defining your own. You should be able to copy the entire function from wp-includes/pluggable.php into your plugin (or functions.php) and remove the line that sends out the email.


3

Short version: As Tom J Nowell said, You shouldn't cleanup if there's nothing to clean Long version: However, if you put wp_reset_postdata() after (or outside) the loop, it would still work perfectly fine. I have used the function in various scenarios, including something like this: dynamic_sidebar( 'main-sidebar' ); wp_reset_postdata(); The reason ...


3

I hope think this may work. Insert this code into php file or php insert plugin, WooCommerce will no longer change password reset link. function reset_pass_url() { $siteURL = get_option('siteurl'); return "{$siteURL}/wp-login.php?action=lostpassword"; } add_filter( 'lostpassword_url', 'reset_pass_url', 11, 0 );


3

You can use retrieve_password_message hook for that. That filter is applied as this: apply_filters( 'retrieve_password_message', string $message, string $key, string $user_login, WP_User $user_data ) So you'll have access to $user_login of the user. It means, that you can write a filter function that will create random password for that user and then send ...


2

Well, your linked gist is not a reset. Reset implies that it provides you with a blank slate -- that one doesn't, it looks more like normalize.css. There is not official WordPress CSS reset. If you're building a theme you can use what you like. However, there are several WordPress generated CSS classes that you should account for. As long as you do that, ...


2

Set your admin ID and run this statement in your PhpMyAdmin UPDATE wp_users SET user_pass = MD5('12345') WHERE ID=1;


2

I can't see how the "UPDATE after comment" answer works. The documentation for the 'password_reset' hook says "Fires before the user's password is reset.". If you redirect, then exit the password won't get changed. Since I had a similar need I developed my solution to the problem. We still respond to the "password_reset" hook but instead of performing the ...


2

The _s (or Underscores) theme is a great starter theme. It's not a child theme, rather a barebones template that you can build on. It includes many features such as HTML5 templates, custom header, custom background and theme options implementations, custom template tags, 5 sample CSS layouts, starter non-presentational CSS that you can build on, and lots ...


2

There are a few ways to accomplish this; 1) [easy] Send your user to the login screen and have them initiate the forgot password process 2) [moderate] Plugins (there are a few) free WordPress plugins, this looks useful, or you could search http://wordpress.org/plugins/search.php?q=reset+password and probably lots of commercial ones, but here is one 3) [...


2

I've added jQuery( document ).ready(function() { and it works! Final working code below: add_action( 'resetpass_form', 'resettext'); function resettext(){ ?> <script type="text/javascript"> jQuery( document ).ready(function() { jQuery('#resetpassform input#wp-submit').val("Set Password"); }); </script> <?php ...


2

I fixed it. We need decode url with esc_url_raw. Here is solution. <?php $user_data = get_user_by( 'email', 'admin@mysite.com' ) ); $key = get_password_reset_key( $user_data ); $user_login = $user_data->user_login; $url = esc_url_raw( get_permalink( '1' ) . "?action=rp&key=$key&login=" . rawurlencode($user_login) ) . "\r\n"; $message = $url; ...


2

You can add the following to your functions.php to achieve what you are after. The action init doesn't seem to fire in time for what you are looking for. if($_GET['action']==='rp' && strpos($_SERVER['REQUEST_URI'],'wp-login.php')) { $key = isset( $_GET['key'] ) ? $_GET['key'] : ''; $login = isset( $_GET['login'] ) ? $_GET['login'] : ''; ...


Only top voted, non community-wiki answers of a minimum length are eligible