Forum Replies Created

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter coty10

    (@coty10)

    Hello, @stylemix
    here’s the link:

    https://etns.eu/project/robigo-it/

    Thank you

    • This reply was modified 4 years, 9 months ago by coty10.
    Thread Starter coty10

    (@coty10)

    Hello. No i’m not using single quote.
    And it keeps making the error.. i got 1000 and more times the same error. Is like it never ends the process

    Thread Starter coty10

    (@coty10)

    Exactly i’m getting the username from the page slug and than applying it directly to the shortcode:

    global $wp;
    $current_url = home_url( $wp->request );
    $username = array_slice(explode('/', $current_url), -1)[0];
    <p><?php echo do_shortcode('[site_reviews_summary category='.$username.']');?></p

    Thank you! ??

    Thread Starter coty10

    (@coty10)

    Thread Starter coty10

    (@coty10)

    Hello!
    Thanks! sounds like a good news!

    However i do need to set it dynamically…
    I have solved like this:

    I create the taxonomy as soon as a new user register.
    Than i’ve created a custom template where i get the page slug, extract the last part of it (which is the username of the user) and then use it to get the reviews.

    Here’s the code:

    <?php 
      global $wp;
      $current_url = home_url( $wp->request );
      $username = array_slice(explode('/', $current_url), -1)[0];
    ?>
    <div class="tab__content">
    <h3>Reviews</h3>
    <p><?php echo do_shortcode('[site_reviews category='.$username.']');?></p>
    </div>
    <div class="tab__content">
    <h3>write a review</h3>
    <p><?php echo do_shortcode('[site_reviews_form category='.$username.']');?></p>
    </div>

    I’m not sure if there is a better way to get the user informations.
    This is a normal wordpress user, but i’m not sure how to get the data (user_login).
    I know how to get the current user data but haven’t find a way to get data of the user in the public page.
    If you have any suggestion i will really appreciate it! ??

    Thank you for your help! ??

    • This reply was modified 4 years, 10 months ago by coty10.
    • This reply was modified 4 years, 10 months ago by coty10.
    Thread Starter coty10

    (@coty10)

    Ok thank you for your reply.

    Thread Starter coty10

    (@coty10)

    ok thank you!
    I’ll contact them.

    Thread Starter coty10

    (@coty10)

    This is the function i use:

    add_action('user_register','username_insert_category');
    function username_insert_category($user_id) {
    	 $user_info = get_userdata($user_id);
         $usernameToLogin = $user_info->user_login;
    		if (!empty($usernameToLogin) && !term_exists($usernameToLogin, glsr()->taxonomy)) {
    				require_once ABSPATH.'wp-admin/includes/taxonomy.php';
    				wp_create_term($term, glsr()->taxonomy);
    		}
    }

    and it works fine.
    The problem is the i have a plugin for membership and in the wp editor i get the username with this constant : {username}
    So when i use the shortcode [site_reviews category=”{username}”] it will bring up all the reviews and not just the one belonging to the category.
    instead if hard code the value [site_reviews category=”test”]
    it works fine. I’m afraid that the shortcode is processed before that information {username} is available. In the inspector i see the correct value

    screenshot

    but it loads the wrong reviews. There are no reviews with test category and yet it loads up all the review

    Thread Starter coty10

    (@coty10)

    I think i get where the problem is…

    i have this [site_reviews category=”{username}”]
    and it won’t work… probably because the {username} value appears after the page is loaded.

    I have test to hard fill the field and it works…

    is there a way where i can use the var {username} and make it work?
    Or the only way is to modify the php file?

    thank you!

    • This reply was modified 4 years, 10 months ago by coty10.
    Thread Starter coty10

    (@coty10)

    I have created a category with the username:

    add_action('user_register','email_insert_category');
    function email_insert_category($user_id) {
    	 $user_info = get_userdata($user_id);
         $usernameToLogin = $user_info->user_login;
    	wp_insert_term(
    		$usernameToLogin,
    		'category',
    		array(
    		  'slug' => $usernameToLogin,
              'parent'=> term_exists( 'Utenti', 'category' )['term_id']
    		)
    	);
    }
    

    and i have the username available in the page ({username})

    Can i use the short code like this: ?

    [site_reviews_form category=”{username}”]

    Thank you!

    • This reply was modified 4 years, 10 months ago by coty10.
    • This reply was modified 4 years, 10 months ago by coty10.
    Thread Starter coty10

    (@coty10)

    Hello.
    I’m on localhost in developing…
    Anyway I’ve solved it with a different plugin.
    Thank you!

Viewing 11 replies - 1 through 11 (of 11 total)