Access code/password only restricts page access, no user registration..?

This is a built-in feature of WordPress. Create a page like you normally would. Then look at the Publish box in the upper-right corner for where it says “Visibility: Public.” Click “Public” and you’ll see some other options – “Private” and “Password Protected.” You want “Password Protected.” Check the appropriate box and enter the password … Read more

How to restrict a page [without plugin]

You can do this pretty easily with a shortcode. Hook into init and add the shortcode in your hooked function. <?php add_action(‘init’, ‘wpse57819_add_shortcode’); /** * Adds the shortcode * * @uses add_shortcode * @return null */ function wpse57819_add_shortcode() { add_shortcode(‘restricted’, ‘wpse57819_shortcode_cb’); } Then in your callback function, you can check to see if the user … Read more

Temporarily disable user role login and replace with message

With a some digging and learning, I managed to combine various help and create these 2 functions… // MAINTAINANCE MODE function site_maintenance() { if ( current_user_can(‘media’) || current_user_can(‘genpo’) ) { $logout_url = wp_login_url().’?mode=maintainance’; wp_logout(); wp_redirect( $logout_url, 302 ); } } add_action(‘get_header’, ‘site_maintenance’); // CUSTOM LOGIN MESSAGES function my_login_message() { if( $_GET[‘mode’] == ‘maintainance’ ){ $message=”<p … Read more

How can I hide media library images from general users?

To let the current users only view his/her uploaded attachments, add the following code to your themes actions: add_filter( ‘posts_where’, ‘devplus_wpquery_where’ ); function devplus_wpquery_where( $where ){ global $current_user; if( is_user_logged_in() ){ // logged in user, but are we viewing the library? if( isset( $_POST[‘action’] ) && ( $_POST[‘action’] == ‘query-attachments’ ) ){ // here you … Read more

Basic auth WordPress REST API dilemma

Basic auth is a very common username/password authentication method and it’s as strong as the username-password combination and the encryption of the protocol you’re using. The weakness of basic auth is that if you use it with plain http instead of https then the username and password is susceptible to a man-in-the-middle attack. You can … Read more

How do you add a custom option to user data?

To add a field to the profile/user edit page you need to use the edit_user_profile hook and show_user_profile hook so: add_action( ‘show_user_profile’, ‘my_extra_user_fields’ ); add_action( ‘edit_user_profile’, ‘my_extra_user_fields’ ); function my_extra_user_fields( $user ) { ?> <h3>User avatar</h3> <table class=”form-table”> <tr> <th><label for=”user_avatar”>User avatar</label></th> <td> <input id=”user_avatar” name=”user_avatar” type=”text” value=” <?php $user_avatar = get_the_author_meta( ‘user_avatar’, $user->ID ); … Read more

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