Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all 8245 articles
Browse latest View live

DTEInc on "add cost based on attribute"

$
0
0

We sell reagents and some of them are 'Hazardous'. Is there a way to have this attribute when it is set to 'Yes', add $XX.XX to the cost automatically at the checkout as an adder? If not, can it be shown as an adder in the product page? And finally, in the event the customer chooses to pick the item up themselves, 'Will Call', have no price added to the cart?
Here is a link to show the product..
Buffer Solution

Any help would be appreciated.


Roland on "Set comment notification recipient per post (non-author)"

$
0
0

We use Wordpress as an intranet CMS where there are three users (authors/admins) that post on behalf of other coworkers (over 100 in total, 20-some 'send in' posts, a.k.a. true authors, all users are registered users).

In order to streamline the commenting system, specifically comment notifications, we would like to be able to input the e-mail address of the post's true author somewhere, so that they will receive an e-mail when someone posts a comment to 'their post'.

I imagine this should be possible using a custom field (preferably choosing the true author so that the name and e-mail from their profile get used) and a function that calls the name and e-mail to hook into the comment e-mail function, but I'm no programmer...

Is this doable or is there already a plugin that does this?

bmmtstb on "Show sth on the Sidebar and easy deactivate it"

$
0
0

Hello,
i've used PHP inside the Sidebar to show a Message.

<?php $HKS_geschlossen = TRUE; ?>
<?php if ( $HKS_geschlossen): ?>
TEXT
<?php endif ;?>

My problem now is, that I have some more People using that Site, who have to change the Value of $HKS_geschlossen. Is there a Way to create sth like a Checkbox in the Admin-Bar where people with rights can change the Value? Thats what I thought is easy to use for "non-coders". If that doesn't work, does sb. know another way to simply change a Value to display/not display a part in the sidebar?

Site is: blog.schwimm-club.de

Martin

bradklosterman on "add_user_page (profile sub menu) with meta fields input"

$
0
0

Create multiple user_page (sub-page for profile menu page on the administration screen) on the admin_menu of an author. The function of each each page displays a screen that has user meta input fields and save button. The data needs placed in a pdf ready for print. This is what I have. I need to place user meta fields in each page. Any suggestions would be greatly appreciated.

add_action('admin_menu', 'my_users_menu');

function my_users_menu() {
add_users_page(__('Education and Qualifications ','userinfo2'), __('Education and Qualifications','userinfo2'), 'read', 'userinfo2', 'userinfo2');
add_users_page('Voluntary Experience', 'Voluntary Experience', 'read', 'userinfo3', 'userinfo3');
}

function userinfo2() {
if ( !current_user_can( 'read' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
echo '<div class="wrapfile">';
echo '<p>Here is where the form would go if I actually had options.</p>';
echo '</div>';
}

function userinfo3() {
if ( !current_user_can( 'read' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
echo '<div class="wrapfile">';
echo '<p>Here is where the form would go if I actually had options.</p>';
echo '</div>';
}

pallemax on "Problems with wp-club-manager"

$
0
0

I am using the latest version of Wp Club Manager and WordPress , but in my "players" section i get this message:

Warning: Illegal offset type in /home/thappo/public_html/wp-content/plugins/wp-club-manager/templates/shortcodes/players.php on line 192

I first used Wp Club Manager and WordPress about a year ago and they worked fine, until now, no changes has been done since.

Is there somekind of compability issue or am i missing somethink obvious?

http://www.teamhappo.com/pelaajat/

marcin1990 on "cron do not upload images"

$
0
0

I let the task CRON product imports. The data are retrieved from the database in a loop. Each item has its own image, and in the database is only information which the link is located. I have this code. When you release the script manually add products properly. While connecting to the cron script is added to the product description and the script stops running. Folder uploads in HR, there is nothing thrown (in the case of manual firing script to a folder are uploaded image from the link).

My code to upload and load pictures. (When I delete this part of the code cron works and products are imported correctly)

$thumb_url = $foto1;
$tmp = download_url( $thumb_url );

preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $thumb_url, $matches);
$file_array['name'] = basename($matches[0]);
$file_array['tmp_name'] = $tmp;

$thumbid = media_handle_sideload( $file_array, $new_post_id, 'gallery desc' );

set_post_thumbnail($new_post_id, $thumbid);

$thumb_url2 = $foto2;

$tmp2 = download_url( $thumb_url2 );

preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $thumb_url2, $matches);

$file_array2['name'] = basename($matches[0]);
$file_array2['tmp_name'] = $tmp2;

$imgID = media_handle_sideload( $file_array2, $new_post_id, 'desc' );

update_post_meta( $new_post_id, '_product_image_gallery', $imgID);

I spent two days. The problem with access rights to the record? Wrong code? What could be causing this?

ivanweb on "Translations list on the plugin page"

$
0
0

Hello!

Could you please help me to understand - how I can change list of available translations on the plugin page in the repository?

I have published plugin https://wordpress.org/plugins/popup4phone/ , in the /lang/ sub directory it contatins .po and .mo files for Russian and German translation.

However translations list in the right column on the page https://wordpress.org/plugins/popup4phone/ contains only Russian translation, while German translation not appeared.

lorbe on "5 installs have been hacked on the same server"

$
0
0

Hi, I'm at my wits end with this issue I've been having for the past 6 months on my server. I do small informational websites on the side for some quick cash when I need it. I currently have five clients running on my server with 5 different versions of WordPress. Whoever has gained access has access to the whole server and is able to upload entire php files into most directories. They are also editing already existing files with things like this: https://gist.github.com/lorbewabo/5f72cf1c1551ecf66a43 ... I have been going into ever directory and manually checking for and deleting this type of code injected into the beginning of the file. I find VERY large directories with pages of junk about other websites. I suspect the purpose of this hack is to gain search rankings on google. I have also been finding things like this: https://gist.github.com/lorbewabo/4450213e6592ec45ef84 which I'm guessing has to do with search engines again. I find very large files that are encrypted as well. The hack has locked me out of the back end a few times and taken some of the sites down more than once, returning a php error. I have went through all of my non essential and questionable plugins, deleting everything that seemed like it would be causing the issue to no avail. Every time I think I've found it, more code is injected. Any help at all is much appreciated. I can provided more details upon request.

Thanks!


WongKentir on "Custom posts type with custom taxonomy"

$
0
0

I having some difficulty figuring out how to query a custom post type in a specific (custom) taxonomy.

So far I have the following code:

<?php query_posts( array('post_type' => array('post','tvshows'), 'showposts' => $nitem, 'orderby' => 'date' )); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php   if (has_post_thumbnail()) {
$imgsrc = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),'medium');
$imgsrc = $imgsrc[0];
} elseif ($postimages = get_children("post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=0")) {
foreach($postimages as $postimage) {
$imgsrc = wp_get_attachment_image_src($postimage->ID, 'medium');
$imgsrc = $imgsrc[0];
}
} elseif (preg_match('/<img [^>]*src=["|\']([^"|\']+)/i', get_the_content(), $match) != FALSE) {
$imgsrc = $match[1];
} else {
$img = get_post_custom_values('poster_url');
$imgsrc = $img[0];
} ?>

I have tax for "cast". For example use the name: alexandro. How to filter post by my taxonomy? I've tried, but fail. :(

jbo.ciel on "custom page in php to update multiple posts"

$
0
0

Hello,

The situation:
- i have installed a wordpress which works well at this domain: http://www.custom-domain.com
- i would like to add a page, for example http://www.custom-domain.com/up.php, which update some posts on loading.

As it is temporally and i get hundreds posts to update, i don't want to use the back-office and neither an import plugin. I get the field to update as a plain text list. An additional difficulty, some filed are ACF ones and not yet fill in the post (the row doesn't exist in the wp_postmeta table).

So i create up.php in the root WP directory like that:

<?php

require( dirname( __FILE__ ) . '/wp-blog-header.php' );

$my_post = array(
array(
	'ID' => 9924,
	'chapo' => 'Lorem Ipsum',
	'_chapo' => 'field_5458ff1e418c7', // ACF Field
),
 array(
	'ID' => 12039,
	'chapo' => 'Zombie Ipsum',
	'_chapo' => 'field_5458ff1e418c7',
),
);

function update($post_list) {
	foreach ( $post_list as $post ) {
		$post_ID = $post['ID'];
		$post_title = get_the_title($post_ID);
		wp_update_post( $post );
		// update_post_meta( $post_ID, 'chapo', $post['chapo'] );
		printf ("%u - %s ok<br/>",$post_ID,$post_title);
	}
};

update($my_post);

?>

The script seems to works but the wp_update_post doesn't. My custom field is not update.

Could it be a problem with the WP function? With the position of the page?
Could it be a problem of right?
Do i have to change the way of doing this?

Thank you in advance for any help.
jbo

carldeary on "Relationship between two taxonomies and a custom post type"

$
0
0

Hi

I need of some help please! Would be much appreciated as I am battling with this one.

See links below along with the scenario.

Test Site: <a
http://www.ileaddesign.co.za/scw/
Brand Link:
http://www.ileaddesign.co.za/scw/product-brand/brands/fullvision/

This is what I have have:

CPT: products
2 x Taxonomies: product_categories / product_brands

You add a product and allocate the product to a category (product_categories) and allocate it to a brand (product_brands).

Under the products page (taxonomy-product_categories.php) you drill down through the different categories till you reach the single product. On the single product you will see that the brand is displayed. I used this tutorial to get this result. The idea is to keep navigating through the categories - http://code.tutsplus.com/articles/create-a-product-listing-with-infinite-categories-using-custom-post-types--wp-23447

I created another template (taxonomy-product_brands.php) to display the brands title, brands description...and the idea is to do exactly as the (taxonomy-product_categories.php) but display the categories related to that specific brand?

I am I correct in doing it the way I have done it? By creating another taxonomy called brand_categories?

<?php
  get_header();

  $slug_products = get_query_var( 'term' );
  $term_products = get_term_by( 'slug', $slug_products, 'product_categories' );
  $term_id_products = $term_products->term_id;

  $slug_brands = get_query_var( 'term' );
  $term_brands = get_term_by( 'slug', $slug_brands, 'product_brands' );
  $term_id_brands = $term_brands->term_id;
?>

<?php // get_template_part( 'parts/featured-image' ); ?>

<div class="row" style="padding-bottom: 40px;">

  <?php get_sidebar( 'left' ); ?>

  <div class="small-12 large-8 columns right" role="main">
  <?php do_action( 'foundationpress_before_content' ); ?>

    <article <?php post_class() ?>>
      <?php do_action( 'foundationpress_page_before_entry_content' ); ?>

      <div class="entry-content">

        <header><h2 class="entry-title"><?php echo $term_brands->name; ?></h2></header>

        <?php
          if ( function_exists('yoast_breadcrumb') ) {
            yoast_breadcrumb('<div id="breadcrumbs">','</div>');
          }
        ?>

        <p><?php echo $term_brands->description; ?></p>

        <?php
          $args=array(
            'post_type' => 'products',

            'tax_query' => array(
              'relation' => 'AND',

              array(
                'taxonomy'      => 'product_categories',
                'hide_empty'    => 0,
                'parent'        => $term_id_products,
                'terms'         => $term_products,
                'field'         => 'slug',
              ),

              array(
                'taxonomy'      => 'product_brands',
                'hide_empty'    => 0,
                'parent'        => $term_id_brands,
                'terms'         => $term_brands,
                'field'         => 'slug',
              )
            )
          );

          $categories=get_categories($args);

          if(!$categories){

          //get the product category name
          echo "<h3>' .$term_brands->name. ' Products</h3>";

          $args = array(
            'posts_per_page' => 50, //remember posts per page should be less or more that what's set in general settings
            'paged' => $paged,
            'order' => 'ASC',
            'tax_query' => array(
              'relation' => 'AND',

              array(
                'taxonomy'      => 'product_categories',
                'hide_empty'    => 0,
                'parent'        => $term_id_products,
                'terms'         => $term_products,
                'field'         => 'slug',
              ),

              array(
                'taxonomy'      => 'product_brands',
                'hide_empty'    => 0,
                'parent'        => $term_id_brands,
                'terms'         => $term_brands,
                'field'         => 'slug',
              )
            )
          );
        ?>

        <!-- if there are no subcategories output current product category's products -->
        <?php
          $products_query = new WP_Query($args);
          if (have_posts()) : while($products_query->have_posts()) : $products_query->the_post();

          $thumb_url = get_option('taxonomy_image_plugin');
        ?>

        <div class="large-4 column product-cat end" onclick="location.href='<?php echo get_permalink(); ?>';">
          <div class="panel" data-equalizer-watch>
            <div class="prod-img">

              <?php
                if ( has_post_thumbnail( $post->ID ) ) :
                  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
                  $image = $image[0];
                  echo '<img src=" ' . $image . ' " />';
                endif;
              ?>

            </div>
          </div>

          <a class="cat-title" href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a>
        </div>

        <?php endwhile; endif; ?>

        <?php } else {

          //output current category name - MOST OF THE ACTION IS HERE
          echo '<h3>'.$term_brands->name.' Products</h3>';

          foreach($categories as $category) {
            $product_cat_url = get_term_link( $category->slug, 'product_categories' );
            // $product_cat_url = get_term_link( $term_products, 'product_categories' );

            $thumb_url = get_option('taxonomy_image_plugin');
        ?>

        <div class="large-4 medium-4 column product-cat" onclick="location.href='<?php echo $product_cat_url ; ?>';">
          <div class="panel" data-equalizer-watch>
            <div class="prod-img"><img src="<?php echo wp_get_attachment_url( $thumb_url[$category->term_id]); ?>" /></div>
          </div>

          <a class="cat-title" href="<?php echo $product_cat_url ; ?>"><?php echo $category->name; ?></a>
        </div>

      <?php } } ?>

      </div> <!--end of entry-->

    </article>

  <?php do_action( 'foundationpress_after_content' ); ?>
  </div><!-- large-8 -->

</div><!-- outer row -->
<?php get_footer(); ?>

JeroenBalk2 on "flush_rewrite_rules with wp_cron"

$
0
0

I'm trying to build myself a plugin for remote viewing data of all my WordPress installations in one overview. Therefore I'm generating a list using xmlrpc to remote connect to all the WordPress instances.

My plugin adds an xmlrpc block to the rewrite rules on plugin activation. The whitelisted IP is variable so the plugin gets my IP from an external source.

This can only work if the plugin automatically flushes rewrite rules and regenerates the htaccess with the most recent whitelisted IP.

I'm using this to schedule my wp_cron.

function remotity_activate() {
    add_filter('mod_rewrite_rules', 'xmlrpc_htaccess_block');
    flush_rewrite_rules();

    wp_schedule_event(time(), 'hourly', 'daily_flush');
}

register_activation_hook( __FILE__, 'remotity_activate' );

add_action('daily_flush', 'force_flush_cron');

function force_flush_cron(){
    flush_rewrite_rules();
}

It succesfully schedules the cron, when I echo the cron via xmlrpc it shows me a valid UNIX timestamp. For testing purposes I scheduled it hourly for now.

I added some nonsense within the START/END tags in the htaccess and checked if it was flushed after an hour but nothing happened.

What am I missing here?

andrew55 on "if logged in and on a certain page, redirect to another specific page?"

$
0
0

I am trying to create a function so if a user is logged in, and they are on certain page, it redirects them to another specific page (unless user is admin). I have this so far but it doesn't work yet:

function my_login_redirect( $url, $request, $user ){
    if( $user && is_object( $user ) && is_a( $user, 'WP_User' ) && is_page(' 4621 ')) {
        if( $user->has_cap( 'administrator' ) ) {
            $url = admin_url();
        } else {
            $url = home_url('https://www.mysite.com/my-page');
        }
    }
    return $url;
}
add_filter('login_redirect', 'my_login_redirect', 10, 3 );

Any ideas on what I'm doing wrong and what I can do to correct this?

Thanks for any help.

casdekkers on "'view_item' shows link for multiple post types"

$
0
0

Hi all,

I have implemented a custom post type named "tournaments" for my blog, and I have had it running for some time now. Recently, someone pointed out that saving a post of type "tournament" shows the correct message: Tournament updated. View tournament. Naturally, View tournament is a link to the correct tournament post. I have set this in my code as follows:

function custom_post_tournaments() {
	$labels = array(
		'name' => _x( 'Tournaments', 'post type general name', 'tournament' ),
		(... etc ...)
		'view_item' => __( 'View Tournament', 'tournament' ),
		(... etc ...)
		'not_found_in_trash' => __( 'No tournaments found in Trash.', 'tournament' )
	);
	$args = array(
		'labels' => $labels,
		'description' => 'Holds all tournaments',
		(... etc ...)
	);
	register_post_type( 'tournament', $args );
}
add_action( 'init', 'custom_post_tournaments' );

However, the message upon saving a post of normal type "post" displays the following notice. Two links, both to the same href, but the View tournament link should not be there.

What's wrong? Thanks for replying.

joe.klovance on "Default menu walker"

$
0
0

Is there a way of registering a menu walker so that it becomes the default?

I am writing a plugin that filters menus based on permissions read from a Codeigniter session. Currently I have to edit the theme to register the new Walker_Nav_Menu. Is there a better way to do this?


manifestwordpress on "Combining wp_mail and wp_redirect in same function - Form Submit Redirect"

$
0
0

Long-time reader of answers, first-time asker of questions...

I have encountered a problem that I cannot debug involving a custom function (defined within the theme's functions.php) that is executed as a form action upon submiting data from a basic HTML form element located in a page template file.

The function gathers the form data (and a few other bits of info from meta fields and theme mods), defines it for use with wp_mail, which is then executed to send an email as defined, the function then executes a redirect to take the user to a thank you page.

Here's the situation: during the localhost portion of development (running WampServer Version 2.2) my function seemed to work just fine, gathering form data and sending the user to correct destination as specified by the wp_redirect location. The email never actually left my virtual server, as I have not configured it for SMTP, so I transferred the theme to a test server running the same version of WordPress to finish beta testing. Now that it is on a real server, the wp_mail side of the function is successfully formatting and sending the email, but rather than loading the redirect location, the function as executed is reloading the source page minus the form element.

Here is a link to the page in question on my test server.

I have tried troubleshooting this problem in the following ways:

1) I have completely removed the wp_mail portion of the function to isolate the wp_redirect portion. The isolated redirect doesn't execute correctly on the live test server, but does on my localhost test server.

2) I have tried defining the location of that redirect in many different ways, including a hard-coded URL, a call to get post meta via the post ID, and then by incorporating the data into the form element as a hidden input, and using the same $form_data method of passing on the field data that is successfully implemented in the mail portion of my function.

3) I have tried manually exiting out of the wp_mail function before calling wp_redirect and have tried removing the suggested manual exit for wp_redirect. When running the function with no exits, the source page reloads on form submission, WITH the form element reloading as normal - but if there is an exit after wp_mail or wp_redirect, the source page reloads WITHOUT the form element.

4) I have tried re-positioning my call to wp_redirect within the function to before the wp_mail reference as well as outside of the if statement.

5) I have checked to make sure that my online server (hosted through GoDaddy) is running the same version of PHP, 5.3, and have even looked at my htaccess file for possible conflicts with the redirect.

The main thing about this problem that confuses me is that the redirect works just fine on my local server in every permutation described above but just plain won't work online. I hope there is an obvious error in my methodology that will lead to a more thorough understanding of core WP functionality - it would hurt my pride, but I want this to be a rookie mistake.

So I think that's the whole scope of the problem, any help identifying the source of this problem would be greatly appreciated - thank you in advance for your attention and support.

This is my custom function:

function mwp_mail() {

	// send to admin email
	$email = get_theme_mod('mwp_mail_to_address', get_bloginfo( 'admin_email' ));
	// if the <form> element is POSTed, run the following code
	if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
	    // this part fetches everything that has been POSTed, sanitizes them and lets us use them as $form_data['subject']
	    foreach ( $_POST as $field => $value ) {
		   $form_data[$field] = sanitize_text_field( $value );
	    }
	   // get the website's name and puts it in front of the subject
	   $email_subject = get_bloginfo( 'name' ) . " - " . $form_data['page'] . " - CTA lead";
	   // get the message from the form and add the IP address of the user below it
	   $email_message = $form_data['your_name'] . " is interested in your service. Contact them at: " . $form_data['email'] . "\n\nIP: " . get_the_ip();
	   // send the e-mail with the post form attribute named 'email' and the POSTed data
	   wp_mail( $email, $email_subject, $email_message );
	   wp_redirect ($form_data['redirect']);
           exit;
	}
}

This is my form markup:

<form name="ctaForm" action="<?php mwp_mail(); ?>" method="post" onsubmit="return validate()">
		<input type="hidden" name="page" id="page" value="<?php echo get_the_title(); ?>"/>
        <input type="hidden" name="redirect" id="redirect" value="<?php echo get_post_meta( get_the_ID(), 'mwp_cta_thankyou', true ); ?>"/>
          <input type="text" id="your_name" name="your_name" value="give us your name"/>
          <input type="text" id="email" name="email" value="and email address"/>
          <input type="submit" value="<?php echo get_post_meta( get_the_ID(), 'mwp_cta_button', true ); ?>" class="CTAbutton"/>
          <input type="button" id="closeCTA" value="X" class="CTAbutton"/>
          <a href="<?php echo get_post_meta( get_the_ID(), 'mwp_cta_pplink', true ); ?>" target="new" class="privacyLink">Privacy Policy</a>
</form>

And for good measure, my htaccess file:

#Alternate default index page
DirectoryIndex welcome.html index.php index.html

# Custom 404 errors
ErrorDocument 404 /404.html

# BEGIN WordPress

# END WordPress

Thanks for reading. Hope you can help me!

Code Tides on "Capturing Domain name whose install my plugin"

$
0
0

Hi, i have a free wordpress plugin hosted on wordpress.org, in that plugin i have done the code where it is capturing the domain name of plugin installed,so i know who is installing my plugin so i can improve it more or make plugins according to the needs.

My question is that, is it legal or not? will i remove my plugin from wordpress.org or stay hosted on wordpress.org?

Any suggestion or experienced programmer comments highly appreciated.

Benjamin Rothman on "query only finds first 10 posts"

$
0
0

I wrote a simple query (shown below) and for some reason it is only finding and showing the first 10 posts of type 'album' that exist. I even tried adding another post of type 'album' and it just started showing that one and 9 of the old ones.

<?php
    query_posts(array( // write the query by setting rules for the query in an array and putting it inside query_posts
        'post_type' => 'album'
    ) );
?>

<div id="albums_container" class='row'>
  <?php while (have_posts()) : the_post(); ?>
      <?php $post = get_post(); ?> <!-- capture the current post with the $post variable -->
      <?php $ID = $post->ID;?> <!-- set $ID to the ID of the current post -->

      <div class="col-sm-12 col-md-4 col-lg-4 design album_container">
        <img src="<?php the_field('cover_art'); ?>" />
      </div>

  <?php endwhile;?>
</div>

Lancelotkiin on "Trouble with Wordpress Ajax Login System - 302"

$
0
0

Hi,

I'm trying to create a simple Ajax Login system with Wordpress.
Unfortunately, every time the "wp_signon" function is fired, my system failed and the only information I have is this one :

POST myurl/wp-admin/admin-ajax.php - 302 Found
GET myurl/?login = failed - 200 Found

So, whether I try to log in with the good informations or not, my JS script goes in the "error part" of my Ajax function.

Can anyone tell me what I a doing wrong? It will be much appreciated!

Many thanks!

JS :

jQuery(document).on('submit', loginForm, function(event) {

	event.preventDefault();

	var usernameVal = jQuery('.modal-login .login-form #user_login').val();
	var passwordVal = jQuery('.modal-login .login-form #user_pass').val();
	var remembermeField = jQuery('.modal-login .login-form #rememberme');
	var securityVal = jQuery('.modal-login .login-form #security').val();

	if ( remembermeField.prop('checked') ) {
		var remembermeVal = 'true';
	} else {
		var remembermeVal = 'false';
	}

	jQuery.ajax({
		type : "post",
		url : data_front_end_users_management.ajaxurl,
		dataType: 'json',
		data: {
			action: 'AuthUserAjax',
			username: usernameVal,
			password: passwordVal,
			rememberme: remembermeVal,
			security: securityVal
		},
		success: function(data) {

			if ( data['answer'] === 1 ) {

				modalAlert( msgRow, msgAlert, msgContent, false, 'alert-success', 'alert-danger', data['message'] );

			} else {

				modalAlert( msgRow, msgAlert, msgContent, false, 'alert-danger', 'alert-success', data['message'] );

			}

		//END success
		},
		error: function () {

			modalAlert( msgRow, msgAlert, msgContent, false, 'alert-danger', 'alert-success', defaultError );

		}

	//END ajax
	});

//END jQuery(document).on('submit', loginForm, function(event)
});

ACTION :

function AuthUserAjax() {

	$LoginController = new FELoginController();

	$value = array();
	$value['answer'] = 0;
	$value['message'] = '';

	$username = trim($_POST['username']);
	$password = trim($_POST['password']);
	$rememberme = $_POST['rememberme'];
	$security = $_POST['security'];

	if ( $LoginController->checkAuthInfosFilled( $username, $password ) ) {

		$user = $LoginController->UserAuth( $username, $password, $rememberme );

		if ( $user ) {

			if ( is_wp_error( $user ) ) {

				$value['answer'] = 0;
				$value['message'] = $user->get_error_message();

			} else {

				$value['answer'] = 1;
				$value['message'] = 'Success.';

			}

		//END if ( $user )
		} else {

			$value['answer'] = 0;
			$value['message'] = 'Wrong username or password.';

		}

	} else {

		$value['answer'] = 0;
		$value['message'] = 'Please, enter your username and your password.';

	}

	$data = json_encode($value);

	die( $data );

//END AuthUserAjax
}

add_action( 'wp_ajax_AuthUserAjax','AuthUserAjax' );
add_action( 'wp_ajax_nopriv_AuthUserAjax','AuthUserAjax' );

CONTROLLER :

public function UserAuth( $username, $password, $rememberme ) {

	if ( check_ajax_referer( 'ajax-login-nonce', 'security' ) ) {

		$creds = array();
		$creds['user_login'] = $username;
		$creds['user_password'] = $password;

		if ( $rememberme == 'true' || $rememberme == true ) {
			$creds['remember'] = true;
		} else {
			$creds['remember'] = false;
		}

		$user = wp_signon( $creds, false );

		return $user;

	} else {

		return false;

	}

//END UserAuth
}

fellerk on "How do I eliminate inappropriate words on my pages"

$
0
0

There are 2 underscored inappropriate words at the bottom of every page of my website. My website is www.auburnreadingcenter.com

Viewing all 8245 articles
Browse latest View live




Latest Images