Tag Info

New answers tagged

-1

I was able to accomplish this by using GravityForms and their registration addon... You have to select "UPDATE" user, instead of "create." Awesome plugin! :)


0

Contributor has the following capabilities delete_posts edit_posts read You can create the "Seller" role to have same capabilities as Contributor add_role( 'seller', __( 'Seller' ), array( 'read' => true, 'edit_posts' => true, 'delete_posts' => true, ) ); Warning from codex NB: This setting ...


1

Add to your functions file and use wp_nav_menu_items add_filter('wp_nav_menu_items','wpsites_add_avatar_to_nav', 10, 2); function wpsites_add_avatar_to_nav( $items, $args ) { if( $args->theme_location == 'primary' ) return $items; $dude = get_avatar( get_current_user_id(), 48 ); if (is_user_logged_in()) : echo'<li ...


1

You can try this out : <?php global $my_profile; ?> <?php if (is_user_logged_in()){ $avatar = '<div class="img" data-key="profile">'.get_avatar( get_current_user_id(), 64 ).'</div>'; }else{ $avatar = ''; } ?> And your menu code should be like this $defaults = array( 'theme_location' => 'location of menu in ...


1

There are two issues with what your form is currently trying to do: action="page-rebrander.php" is meaningless to WP (if you actually do have such custom file β€” you shouldn't). In WP mechanics you should be typically submitting form to the page itself, options.php (for Settings API), or admin-post.php (for more generic forms). You are trying to pass data ...


0

The full answer is that you could code it by hand or use a plugin. :) Many form plugins, however, generate loads of HTML and CSS already, and due to the fact that styling forms is a huge pain (even for a CSS geek like me), you'd be writing tons of CSS overrides to overcome the aggressive coding of, say, Gravity Forms or the like. I spent a huge amount of ...


0

what framework do you use for your theme-panel? You need to make image upload into your theme panel page and a line of code to call it everywhere of your theme you want. This is an example: in theme panel function page $options[] = array( 'name' => __('Introduction Image', 'options_check'), 'desc' => __('This is your site logo.', ...


1

I solved the issue. Basically, in my code I was storing the data after getting the html, so I just moved the storing code above where I get the html and it worked ..


3

<?php class someClass { public function __construct($options = null, $initialize = true, $error_messages = null, $path, $qnty) { //construct what you see fit here.... } //etc.. } // Action listener add_action( 'action_name', create_function('', "new someClass(implode(',',func_get_args()));"), 10, 5 // IMPORTANT, ...


2

You can not execute functions inside the do_shortcode() call like you are trying to. If you are just trying to wrap your post meta content with the shortcode, then you can do it like shown below. $your_post_meta_variable_content = get_post_meta( $postid, principal_1, true ); echo do_shortcode( '[learn_more caption="ancila"]' . ...


-1

Finally a solution provide by @Rizier123 if(!preg_match("/" . preg_quote($citation_string, "/") . "/", $footer_contents)) @Rizier123 say : The problem are the slashes in your pattern, just use preg_quote() to escape them, e.g. so the code will be like this : add_action('template_redirect', 'foobar_explode_if_no_citation'); function ...


0

First thing get_current_theme() is deprecated since version 3.4 you need to use wp get theme() to get the current theme name. And about add_menu() you can only use it at action hook admin_bar_menu as codex say about it: This is not a function. It is a method of the $wp_admin_bar global (an instance of WP_Admin_Bar), which may not exist except during the ...


0

I will approach like this: global $current_user; get_currentuserinfo(); $email = (string) $current_user->user_email; var_dump($email); You just called got the email from the current_user array and cast it into string :) that's it


0

Found the answer, created the following function: function wscu_sanitize_user ($username, $raw_username, $strict) { $username = wp_strip_all_tags ($raw_username); return $username; } add_filter ('sanitize_user', 'wscu_sanitize_user', 10, 3);


0

There is a discussion on woocommerces' github about splitting language files with reference to a WP file called makepot.php that will split them. Maybe this code will direct you? github.com/woothemes/woocommerce/issues/2051


0

If you just need to "Get Current user email as a return string value" then you can simply do this by using following function // Add this function in your functions.php or in your plugin function mm_get_current_user_email(){ global $current_user; get_currentuserinfo(); $email = $current_user->user_email; return $email; } ...


1

Are you creating your users via regular means or somehow importing them? Trying to create such user WP prevents me from doing so: ERROR: This username is invalid because it uses illegal characters. Please enter a valid username. The reason for that is that username is validated with validate_username(), which runs sanitize_user() in strict mode. That ...


0

You want to "reverse" your logic, in a sense. You need "not (home or front)", not "not home and not front". For example: // var_dump(is_home(),is_front_page(),(is_home() || is_front_page()),!(is_home() || is_front_page())); // debug if ( !(is_home() || is_front_page()) ) { echo "Hello World"; } else { echo "Else World"; } An easier, more readable way ...


1

You can use page id as mentioned by @vee s answer. For Eg: If you want to echo Hello world on front page, page id 1, and 2 with echo Else world for all other pages, use: <?php if ( ( is_front_page() ) && ( is_page(1) || is_page(2) ) ) { echo "Hello World"; } else { echo "Else world"; ?> For more info: ...


0

If you are going to develop this yourself, then it would certainly be recommended to write your own plugin. However, if you have no experience of doing that, you might want to see what is already available. This plugin looks like it might do the job but please note that I have never used it myself. If you do go down the develop-it-yourself route, I would ...


0

Put all the page Ids in an array for which you do not want to show the div. Try the following code. global $post; $posts_array = array(1); $current_page_id = $post->ID; if ( (! is_front_page() ) && ( ! in_array( $current_page_id, $posts_array ) ) ) { echo "Hello World"; }


0

Use this. <?php if ( (!is_front_page() ) && (is_page (14) || is_page(25) || .... ) ) { echo "Hello World"; } ?>


1

Another safer alternative to this problem is using get_queried_object() which holds the current queried object to get the page slug which is held by the post_name property. This can be used anywhere in your template. $post can be used, but it can be unreliable as any custom query or custom code can change the value of $post, so it should be avoided outside ...


0

As per other answers slug is stored in post_name property. While it could be accessed directly I prefer the (underused) get_post_field() function for access post properties which have no proper API for them. It requires post provided explicitly and doesn't default to the current one, so in full for current post it would be: $slug = get_post_field( ...


0

For question as stated it would be easiest to retrieve page's slug and pass it as second argument: get_template_part( 'content', get_post_field( 'post_name', get_post() ) ); Note that you would want to have generic content.php for pages that don't have dedicated template (if any).


1

If you push a "search" through WP_User_query you will search both the user_login fields and the user_nicename fields. That produces a de facto inefficient OR query. You can reduce that by using a filter to force the search to only the user_nicename field. add_filter('user_search_columns','nicename_only_wpse_188846'); function ...


2

I think you should use the default class for this job - WP_User_Query. The query have a lot of possibilities, also get the display name. WP_User_Query is a class that allows querying WordPress database tables _users and _usermeta. Also it is helpful when you use a cache for the values. Also here I prefer the WordPress defaults WP_Cache (Non-Persistent ...


0

The following worked for me. functions.php function add_query_vars_filter( $vars ){ $vars[] = "ref"; return $vars; } custom template <?php if($_GET['ref'] == 'special') :?> //do something <?php else: ?> //do something <?php endif ;?>


0

a $_GET variable would be the better option. try var_dump($_GET); on the page before the conditional and see exactly what you need to test against It seems that there is something more to the puzzle that we are missing. Is the file not showing up correctly? Could that be because the file paths are wrong? Or is it always showing the wrong image? Also, I ...


5

You can use get_the_title() to return the current post title in the loop.


0

You need to check against the value of layout: if ( get_theme_mod( 'layout' ) === 'stream' ) { // Stream } elseif ( get_theme_mod( 'layout' ) === 'grid' ) { // Grid } else { // Fallback }


0

Nice one, you were practically there - the key is to assign the $ecpt_imdb variable with the data returned from get_post_meta: <?php if ( $ecpt_imdb = get_post_meta( get_the_ID(), 'ecpt_imdb', true ) ) : ?> <h3>About the Movie</h3> <?php echo do_shortcode( '[imdb]http://www.imdb.com/title/' . $ecpt_imdb . '/[/imdb]' ) ?> ...


0

You can directly access your Admin Panel through http://localhost/project/wp-admin/ There is no file such as wp-login.php inside your wp-admin directory and there is no need to access it. If you are accessing as a user: Try this: http://localhost/project/wp-login.php


0

It is possible as referenced here but you are talking about a great deal of customization in the Gravity forms plugin and like you said you are not a programmer yourself, so you better open a support ticket in their forums and they might be able to help. Also look at this code that can help you if you decide to do it yourself $upload_dir = ...


0

You need a better function, your paths are broken - see this answer for reference: function wpse_16722_type_upload_dir( $args ) { if ( ! empty( $_REQUEST['post_id'] ) && $post_id = absint( $_REQUEST['post_id'] ) ) { if ( $post = get_post( $post_id ) ) { if ( $post->post_type !== 'attachment' ) { ...


1

That is not how $wpdb->prepare works. You feed prepare a string with sprintf-like placeholders, and the appropriate replacement values. Placeholders The query parameter for prepare accepts sprintf()-like placeholders. The %s (string), %d (integer) and %f (float) formats are supported. (The %s and %d placeholders have been available since the ...


0

That's pretty simple, just use your website home url :) After that, just fire an action when the page is loaded via POST HTTP method and hook with a callback. add_action( 'wp_loaded', function() { if ( $_SERVER['REQUEST_METHOD'] === 'POST' ) { // fire the custom action do_action('onchangeapi', new PostListener($_POST)); } } ); And now ...


0

Here's the JS I use to replace checkboxes for radio buttons. function checktoradio(){ echo '<script type="text/javascript">jQuery("#categorychecklist-pop input, #categorychecklist input, .cat-checklist input").each(function(){this.type="radio"});</script>'; } add_action('admin_footer', 'checktoradio'); This would also work for custom ...


0

As @Tom J Nowell says, don't nest functions. Just write them normally: function my_theme_prefix_setup() { // Add theme support etc. } add_action( 'after_setup_theme', 'my_theme_prefix_setup' ); function my_theme_prefix_init() { // Register a post type } add_action( 'init', 'my_theme_prefix_init' ); Or using a class: class my_theme { ...


0

NOTE: This code is correct above is the solution I was looking for. I just overlooked applying it to some scripts and so I thought it wasn't working.


0

First: I feel the need to ask where exactly are you putting this php code? Hopefully not in the content area of the page through the WordPress Dashboard as php does not work there. (This is the "is it plugged in?" question that needs to be asked first.) You must put all php code inside a .php file in your theme somewhere. Don't feel insulted or stupid, it ...


0

this should work <?php echo do_shortcode('[shortcode_products_by_brand title="Promozioni" per_page="12" columns="4" orderby="title" order="desc" brand="'. $entity->getSlug() .'" operator="IN"]') ?>


0

This ended up being my answer! first i let $form_register = a function containing the form i need with php included in it. then i make a new menu entry in the toolbar and let $form_register be the titel, so now it can keep the values if the user enter something incorrectly so they dont have to start all over again :). hope this helps someone meeting the ...


0

Apart from the horribly format issues you also have a typo: <?php $my_excerpt = $item->post_excerpt; if ($my_excerpt){ echo Str::limit($my_excerpt, 120);} else $content = ($item->post_content);{ ...


0

Please add ";" after $i = $i++ and see if that fixes your issue foreach ($socialIcons as $icon) { $i = $i++; $wp_customize->add_setting( 'pxk_href_' . $icon['name'], // use this in twig file call to theme_mod array( 'default' => '', 'transport' => 'postMessage', 'priority' => $i ) );


2

A neater solution would be to wrap all of the logic and markup into the shortcode itself: function conditional_shortcode_wpse_188037() { global $post; if ( $post->post_author == get_current_user_id() ) { $ret = '<div class="my_edit_button">'; $ret .= 'other shortcode content'; $ret .= '</div>'; return $ret; } } ...


1

Try this <div class="my_edit_button"> <?php if ( $post->post_author == $current_user->ID ) { echo do_shortcode('[something]'); }?> </div>


0

I am not sure what are you trying to get here: Sabai::_h($entity->getSlug()); but Since you are echoing a statement, you need to store the value in a variable first and then call it within the shortcode string. <?php $brand_variable = Sabai::_h($entity->getSlug()); echo do_shortcode('[shortcode_products_by_brand title="Sample brand products" ...


1

Try this way <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td width="100%" valign="top"> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <h2><a href="<?php ...


0

If you're releasing this as a plugin, you absolutely must use the AJAX API. It's super easy: /** * Handle the request and return the result. */ function alumni_process_request() { global $wpdb; // All your processing code from your original question, except for loading WordPress! return $data; } /** * AJAX handler for the "alumni" action. ...



Top 50 recent answers are included